{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "93fee998-917f-4e59-9943-e074b15ca27f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import polars as pl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "85d5fc13-3ec2-4a05-930f-8e1cc292f4c7",
   "metadata": {},
   "outputs": [],
   "source": [
    "df=pl.read_csv(\"stock_trades/202207-湘财.xls\",encoding=\"gb18030\",separator=\"\\t\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "8af5fd50-22df-4738-8938-c0f67e29062f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "polars.dataframe.frame.DataFrame"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "88fb6ccf-f62c-400d-aebc-87a647516740",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(17, 16)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.shape\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "1fe23731-6eee-4a9a-b520-82631e4c6fa6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "17"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.height"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "d494c56e-ae07-4642-8b8a-308cf15ebd69",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "16"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.width"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "c84362d9-e6c0-44db-b43a-104066a4eced",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.is_empty()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "9e35fa42-3a21-4a0a-bfd1-6ae9c472d6fa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Schema([('发生日期', Int64),\n",
       "        ('证券代码', String),\n",
       "        ('证券名称', String),\n",
       "        ('买卖标志', String),\n",
       "        ('业务名称', String),\n",
       "        ('成交时间', String),\n",
       "        ('成交数量', String),\n",
       "        ('成交价格', Float64),\n",
       "        ('成交金额', Float64),\n",
       "        ('发生金额', Float64),\n",
       "        ('手续费', String),\n",
       "        ('印花税', String),\n",
       "        ('过户费', String),\n",
       "        ('其他费', String),\n",
       "        ('备注', String),\n",
       "        ('币种', String)])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.schema"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ddd1295a-2412-465a-82a4-328455378428",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['发生日期',\n",
       " '证券代码',\n",
       " '证券名称',\n",
       " '买卖标志',\n",
       " '业务名称',\n",
       " '成交时间',\n",
       " '成交数量',\n",
       " '成交价格',\n",
       " '成交金额',\n",
       " '发生金额',\n",
       " '手续费',\n",
       " '印花税',\n",
       " '过户费',\n",
       " '其他费',\n",
       " '备注',\n",
       " '币种']"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "66c31ccd-1d1e-4247-8484-c307f55158f9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "list"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(df.columns)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "70c7c438-6edc-49c5-8ba8-25727fcf1263",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "16"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(df.columns)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "1cd82b6a-a00b-4515-899e-8de14bd5fe82",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "type object 'Schema' has no attribute '_base_'",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mAttributeError\u001b[39m                            Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[19]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[38;5;28;43mtype\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mdf\u001b[49m\u001b[43m.\u001b[49m\u001b[43mschema\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43m_base_\u001b[49m._base_\n",
      "\u001b[31mAttributeError\u001b[39m: type object 'Schema' has no attribute '_base_'"
     ]
    }
   ],
   "source": [
    "type(df.schema)._base_._base_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "eaf2d95e-d78e-4588-ad8b-aa0e7537b2b1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Int64,\n",
       " String,\n",
       " String,\n",
       " String,\n",
       " String,\n",
       " String,\n",
       " String,\n",
       " Float64,\n",
       " Float64,\n",
       " Float64,\n",
       " String,\n",
       " String,\n",
       " String,\n",
       " String,\n",
       " String,\n",
       " String]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "641f36b1-6e18-49d7-8f3d-9e7a0fe82336",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(df.schema.keys())==df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "7e3a5598-8c70-45eb-a26d-5a89d290bb96",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (1, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220721</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;卖出&quot;</td><td>&quot;股息入账&quot;</td><td>&quot;16:00:00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>3.6</td><td>4884.0</td><td>4884.0</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;股息入账:赣粤高速600269; 权益股数:40700;&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (1, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ str    ┆ str    ┆ str    ┆ str    │\n",
       "│ i64     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022072 ┆ 600269  ┆ 赣粤高  ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 股息入 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 速      ┆        ┆   ┆ \"      ┆ \"      ┆ 账:赣  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 粤高速 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 600269 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ ; 权益 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 股数:4 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 0700;  ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "54843774-934a-44cb-9def-21691d06446f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (1, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220718</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:03:27&quot;</td><td>&quot;-580.00&quot;</td><td>1.675</td><td>58000.0</td><td>58018.63</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:18.63实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (1, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ str    ┆ str    ┆ str    ┆ str    │\n",
       "│ i64     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022071 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券购 ┆ 人民币 │\n",
       "│ 8       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 回:18. ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 63实际 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 占款天 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 数：7- ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 888880 ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "b22c785d-665f-4b63-8bd1-407ff371e0ad",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (1, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220707</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:17:51&quot;</td><td>&quot;-7580.00&quot;</td><td>2.46</td><td>758000.0</td><td>758357.61</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:357.61实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (1, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ str    ┆ str    ┆ str    ┆ str    │\n",
       "│ i64     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022070 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券购 ┆ 人民币 │\n",
       "│ 7       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 回:357 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ .61实  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 际占款 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 天数： ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 7-8888 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 80     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "115e4839-106b-4685-8e3a-749f540c8b8b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (1, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220718</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:43:38&quot;</td><td>&quot;40700.00&quot;</td><td>3.69</td><td>150183.0</td><td>-150208.53</td><td>&quot;24.03&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.50&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (1, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ str    ┆ str    ┆ str    ┆ str    │\n",
       "│ i64     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022071 ┆ 600269  ┆ 赣粤高  ┆ 买入   ┆ … ┆ 1.50   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 8       ┆         ┆ 速      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "90627472-c7e7-43ce-85b0-0191711e49c5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (2, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220718</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:52&quot;</td><td>&quot;47000.00&quot;</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>&quot;23.99&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.51&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:31&quot;</td><td>&quot;11900.00&quot;</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>&quot;24.00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.49&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (2, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ str    ┆ str    ┆ str    ┆ str    │\n",
       "│ i64     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022071 ┆ 600408  ┆ 安泰集  ┆ 买入   ┆ … ┆ 1.51   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 8       ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 600648  ┆ 外高桥  ┆ 买入   ┆ … ┆ 1.49   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 8       ┆         ┆         ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[3:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "881f497d-b49d-4a95-a8d6-49cfb0d0f764",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (5, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220721</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;卖出&quot;</td><td>&quot;股息入账&quot;</td><td>&quot;16:00:00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>3.6</td><td>4884.0</td><td>4884.0</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;股息入账:赣粤高速600269; 权益股数:40700;&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:03:27&quot;</td><td>&quot;-580.00&quot;</td><td>1.675</td><td>58000.0</td><td>58018.63</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:18.63实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;=&quot;002462&quot;&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;09:38:10&quot;</td><td>&quot;-10400.00&quot;</td><td>13.2062</td><td>137344.0</td><td>137184.67</td><td>&quot;21.98&quot;</td><td>&quot;137.35&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:52&quot;</td><td>&quot;47000.00&quot;</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>&quot;23.99&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.51&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:31&quot;</td><td>&quot;11900.00&quot;</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>&quot;24.00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.49&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (5, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ str    ┆ str    ┆ str    ┆ str    │\n",
       "│ i64     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022072 ┆ 600269  ┆ 赣粤高  ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 股息入 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 速      ┆        ┆   ┆ \"      ┆ \"      ┆ 账:赣  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 粤高速 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 600269 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ ; 权益 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 股数:4 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 0700;  ┆        │\n",
       "│ 2022071 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券购 ┆ 人民币 │\n",
       "│ 8       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 回:18. ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 63实际 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 占款天 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 数：7- ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 888880 ┆        │\n",
       "│ 2022071 ┆ =\"00246 ┆ 嘉事堂  ┆ 卖出   ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 证券卖 ┆ 人民币 │\n",
       "│ 8       ┆ 2\"      ┆         ┆        ┆   ┆        ┆ \"      ┆ 出     ┆        │\n",
       "│ 2022071 ┆ 600408  ┆ 安泰集  ┆ 买入   ┆ … ┆ 1.51   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 8       ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 600648  ┆ 外高桥  ┆ 买入   ┆ … ┆ 1.49   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 8       ┆         ┆         ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "3e8e08bc-0899-4dd8-90b1-6765e18a5e32",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220721</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;卖出&quot;</td><td>&quot;股息入账&quot;</td><td>&quot;16:00:00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>3.6</td><td>4884.0</td><td>4884.0</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;股息入账:赣粤高速600269; 权益股数:40700;&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:03:27&quot;</td><td>&quot;-580.00&quot;</td><td>1.675</td><td>58000.0</td><td>58018.63</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:18.63实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;=&quot;002462&quot;&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;09:38:10&quot;</td><td>&quot;-10400.00&quot;</td><td>13.2062</td><td>137344.0</td><td>137184.67</td><td>&quot;21.98&quot;</td><td>&quot;137.35&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:52&quot;</td><td>&quot;47000.00&quot;</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>&quot;23.99&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.51&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:31&quot;</td><td>&quot;11900.00&quot;</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>&quot;24.00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.49&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>20220711</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;质押回购拆出&quot;</td><td>&quot;09:39:27&quot;</td><td>&quot;580.00&quot;</td><td>1.675</td><td>58000.0</td><td>-58002.9</td><td>&quot;2.90&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券回购购回日:20220718预计利息:18.63参考占款…</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:37:25&quot;</td><td>&quot;54000.00&quot;</td><td>2.59</td><td>139860.0</td><td>-139883.8</td><td>&quot;22.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.42&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:36:30&quot;</td><td>&quot;21400.00&quot;</td><td>6.54</td><td>139956.0</td><td>-139979.8</td><td>&quot;22.39&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.41&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:34:24&quot;</td><td>&quot;38300.00&quot;</td><td>3.65</td><td>139795.0</td><td>-139818.75</td><td>&quot;22.37&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220707</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:17:51&quot;</td><td>&quot;-7580.00&quot;</td><td>2.46</td><td>758000.0</td><td>758357.61</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:357.61实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ str    ┆ str    ┆ str    ┆ str    │\n",
       "│ i64     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022072 ┆ 600269  ┆ 赣粤高  ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 股息入 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 速      ┆        ┆   ┆ \"      ┆ \"      ┆ 账:赣  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 粤高速 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 600269 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ ; 权益 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 股数:4 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 0700;  ┆        │\n",
       "│ 2022071 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券购 ┆ 人民币 │\n",
       "│ 8       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 回:18. ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 63实际 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 占款天 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 数：7- ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 888880 ┆        │\n",
       "│ 2022071 ┆ =\"00246 ┆ 嘉事堂  ┆ 卖出   ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 证券卖 ┆ 人民币 │\n",
       "│ 8       ┆ 2\"      ┆         ┆        ┆   ┆        ┆ \"      ┆ 出     ┆        │\n",
       "│ 2022071 ┆ 600408  ┆ 安泰集  ┆ 买入   ┆ … ┆ 1.51   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 8       ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 600648  ┆ 外高桥  ┆ 买入   ┆ … ┆ 1.49   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 8       ┆         ┆         ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 2022071 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券回 ┆ 人民币 │\n",
       "│ 1       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 购购回 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 日:202 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 20718  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 预计利 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 息:18. ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 63参考 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 占款…  ┆        │\n",
       "│ 2022071 ┆ 601992  ┆ 金隅集  ┆ 买入   ┆ … ┆ 1.42   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 600894  ┆ 广日股  ┆ 买入   ┆ … ┆ 1.41   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 份      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 601077  ┆ 渝农商  ┆ 买入   ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 行      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022070 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券购 ┆ 人民币 │\n",
       "│ 7       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 回:357 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ .61实  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 际占款 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 天数： ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 7-8888 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 80     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "2de1ab23-3cbb-4de7-a3d3-f58f9ccd1c33",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17,)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th></tr><tr><td>str</td></tr></thead><tbody><tr><td>&quot;600269&quot;</td></tr><tr><td>&quot;204007&quot;</td></tr><tr><td>&quot;=&quot;002462&quot;&quot;</td></tr><tr><td>&quot;600408&quot;</td></tr><tr><td>&quot;600648&quot;</td></tr><tr><td>&hellip;</td></tr><tr><td>&quot;204007&quot;</td></tr><tr><td>&quot;601992&quot;</td></tr><tr><td>&quot;600894&quot;</td></tr><tr><td>&quot;601077&quot;</td></tr><tr><td>&quot;204007&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17,)\n",
       "Series: '证券代码' [str]\n",
       "[\n",
       "\t\"600269\"\n",
       "\t\"204007\"\n",
       "\t\"=\"002462\"\"\n",
       "\t\"600408\"\n",
       "\t\"600648\"\n",
       "\t…\n",
       "\t\"204007\"\n",
       "\t\"601992\"\n",
       "\t\"600894\"\n",
       "\t\"601077\"\n",
       "\t\"204007\"\n",
       "]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:,1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "14db7b63-a688-4320-bb9d-ff1352d019a7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17, 2)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th></tr><tr><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td></tr><tr><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td></tr><tr><td>&quot;=&quot;002462&quot;&quot;</td><td>&quot;嘉事堂&quot;</td></tr><tr><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td></tr><tr><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td></tr><tr><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td></tr><tr><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td></tr><tr><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td></tr><tr><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17, 2)\n",
       "┌───────────┬──────────┐\n",
       "│ 证券代码  ┆ 证券名称 │\n",
       "│ ---       ┆ ---      │\n",
       "│ str       ┆ str      │\n",
       "╞═══════════╪══════════╡\n",
       "│ 600269    ┆ 赣粤高速 │\n",
       "│ 204007    ┆ GC007    │\n",
       "│ =\"002462\" ┆ 嘉事堂   │\n",
       "│ 600408    ┆ 安泰集团 │\n",
       "│ 600648    ┆ 外高桥   │\n",
       "│ …         ┆ …        │\n",
       "│ 204007    ┆ GC007    │\n",
       "│ 601992    ┆ 金隅集团 │\n",
       "│ 600894    ┆ 广日股份 │\n",
       "│ 601077    ┆ 渝农商行 │\n",
       "│ 204007    ┆ GC007    │\n",
       "└───────────┴──────────┘"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:,1:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "94bb3d22-54d6-4338-896d-a986fe11b59f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17, 2)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券名称</th><th>成交金额</th></tr><tr><td>str</td><td>f64</td></tr></thead><tbody><tr><td>&quot;赣粤高速&quot;</td><td>4884.0</td></tr><tr><td>&quot;GC007&quot;</td><td>58000.0</td></tr><tr><td>&quot;嘉事堂&quot;</td><td>137344.0</td></tr><tr><td>&quot;安泰集团&quot;</td><td>149930.0</td></tr><tr><td>&quot;外高桥&quot;</td><td>150019.0</td></tr><tr><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;GC007&quot;</td><td>58000.0</td></tr><tr><td>&quot;金隅集团&quot;</td><td>139860.0</td></tr><tr><td>&quot;广日股份&quot;</td><td>139956.0</td></tr><tr><td>&quot;渝农商行&quot;</td><td>139795.0</td></tr><tr><td>&quot;GC007&quot;</td><td>758000.0</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17, 2)\n",
       "┌──────────┬──────────┐\n",
       "│ 证券名称 ┆ 成交金额 │\n",
       "│ ---      ┆ ---      │\n",
       "│ str      ┆ f64      │\n",
       "╞══════════╪══════════╡\n",
       "│ 赣粤高速 ┆ 4884.0   │\n",
       "│ GC007    ┆ 58000.0  │\n",
       "│ 嘉事堂   ┆ 137344.0 │\n",
       "│ 安泰集团 ┆ 149930.0 │\n",
       "│ 外高桥   ┆ 150019.0 │\n",
       "│ …        ┆ …        │\n",
       "│ GC007    ┆ 58000.0  │\n",
       "│ 金隅集团 ┆ 139860.0 │\n",
       "│ 广日股份 ┆ 139956.0 │\n",
       "│ 渝农商行 ┆ 139795.0 │\n",
       "│ GC007    ┆ 758000.0 │\n",
       "└──────────┴──────────┘"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:,[\"证券名称\",\"成交金额\"]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "2126d45f-2304-4f48-a4ae-7da93f2840d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (5, 7)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th></tr><tr><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;赣粤高速&quot;</td><td>&quot;卖出&quot;</td><td>&quot;股息入账&quot;</td><td>&quot;16:00:00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>3.6</td><td>4884.0</td></tr><tr><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:03:27&quot;</td><td>&quot;-580.00&quot;</td><td>1.675</td><td>58000.0</td></tr><tr><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;09:38:10&quot;</td><td>&quot;-10400.00&quot;</td><td>13.2062</td><td>137344.0</td></tr><tr><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:52&quot;</td><td>&quot;47000.00&quot;</td><td>3.19</td><td>149930.0</td></tr><tr><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:31&quot;</td><td>&quot;11900.00&quot;</td><td>12.6066</td><td>150019.0</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (5, 7)\n",
       "┌──────────┬──────────┬───────────┬──────────┬───────────┬──────────┬──────────┐\n",
       "│ 证券名称 ┆ 买卖标志 ┆ 业务名称  ┆ 成交时间 ┆ 成交数量  ┆ 成交价格 ┆ 成交金额 │\n",
       "│ ---      ┆ ---      ┆ ---       ┆ ---      ┆ ---       ┆ ---      ┆ ---      │\n",
       "│ str      ┆ str      ┆ str       ┆ str      ┆ str       ┆ f64      ┆ f64      │\n",
       "╞══════════╪══════════╪═══════════╪══════════╪═══════════╪══════════╪══════════╡\n",
       "│ 赣粤高速 ┆ 卖出     ┆ 股息入账  ┆ 16:00:00 ┆ =\"0.00\"   ┆ 3.6      ┆ 4884.0   │\n",
       "│ GC007    ┆ 卖出     ┆ 拆出质押  ┆ 19:03:27 ┆ -580.00   ┆ 1.675    ┆ 58000.0  │\n",
       "│          ┆          ┆ 购回      ┆          ┆           ┆          ┆          │\n",
       "│ 嘉事堂   ┆ 卖出     ┆ 证券卖出  ┆ 09:38:10 ┆ -10400.00 ┆ 13.2062  ┆ 137344.0 │\n",
       "│ 安泰集团 ┆ 买入     ┆ 证券买入  ┆ 09:44:52 ┆ 47000.00  ┆ 3.19     ┆ 149930.0 │\n",
       "│ 外高桥   ┆ 买入     ┆ 证券买入  ┆ 09:44:31 ┆ 11900.00  ┆ 12.6066  ┆ 150019.0 │\n",
       "└──────────┴──────────┴───────────┴──────────┴───────────┴──────────┴──────────┘"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:5,\"证券名称\":\"成交金额\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "f38cfe2b-87af-446e-96be-b0d08f86c46f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(20220721,\n",
       " '600269',\n",
       " '赣粤高速',\n",
       " '卖出',\n",
       " '股息入账',\n",
       " '16:00:00',\n",
       " '=\"0.00\"',\n",
       " 3.6,\n",
       " 4884.0,\n",
       " 4884.0,\n",
       " '=\"0.00\"',\n",
       " '=\"0.00\"',\n",
       " '=\"0.00\"',\n",
       " '=\"0.00\"',\n",
       " '股息入账:赣粤高速600269; 权益股数:40700;',\n",
       " '人民币')"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.row(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "9b29a0d5-7cff-4e71-9c4b-ef0a1fabc7a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tuple"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(df.row(0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "96568761-63c0-4e05-9455-94e98a2803b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "r = df.rows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "0413ddaa-5398-4ddb-a433-59e36ce17d4a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "list"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(r)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "13d5ae1b-166e-46cb-8482-a08a930cad22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tuple"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(r[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "0c59b1e0-4192-468c-a4d7-3c61b61baa13",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "17"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(r)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "97073d05-c8b9-47a4-a2a5-feb7d91667d9",
   "metadata": {},
   "outputs": [],
   "source": [
    "s = df.get_column(\"成交金额\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "e7c3e724-02de-4bd6-a2ff-145b3af5c7c4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "polars.series.series.Series"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "dda9a0f7-aca3-4c02-9f55-005a6e662117",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17,)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th></tr><tr><td>i64</td></tr></thead><tbody><tr><td>20220721</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>&hellip;</td></tr><tr><td>20220711</td></tr><tr><td>20220711</td></tr><tr><td>20220711</td></tr><tr><td>20220711</td></tr><tr><td>20220707</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17,)\n",
       "Series: '发生日期' [i64]\n",
       "[\n",
       "\t20220721\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t…\n",
       "\t20220711\n",
       "\t20220711\n",
       "\t20220711\n",
       "\t20220711\n",
       "\t20220707\n",
       "]"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_series()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "537e83ca-bee7-42f0-b483-e674c87bc132",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220721</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;卖出&quot;</td><td>&quot;股息入账&quot;</td><td>&quot;16:00:00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>3.6</td><td>4884.0</td><td>4884.0</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;股息入账:赣粤高速600269; 权益股数:40700;&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:03:27&quot;</td><td>&quot;-580.00&quot;</td><td>1.675</td><td>58000.0</td><td>58018.63</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:18.63实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;=&quot;002462&quot;&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;09:38:10&quot;</td><td>&quot;-10400.00&quot;</td><td>13.2062</td><td>137344.0</td><td>137184.67</td><td>&quot;21.98&quot;</td><td>&quot;137.35&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:52&quot;</td><td>&quot;47000.00&quot;</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>&quot;23.99&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.51&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:31&quot;</td><td>&quot;11900.00&quot;</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>&quot;24.00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.49&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>20220711</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;质押回购拆出&quot;</td><td>&quot;09:39:27&quot;</td><td>&quot;580.00&quot;</td><td>1.675</td><td>58000.0</td><td>-58002.9</td><td>&quot;2.90&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券回购购回日:20220718预计利息:18.63参考占款…</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:37:25&quot;</td><td>&quot;54000.00&quot;</td><td>2.59</td><td>139860.0</td><td>-139883.8</td><td>&quot;22.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.42&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:36:30&quot;</td><td>&quot;21400.00&quot;</td><td>6.54</td><td>139956.0</td><td>-139979.8</td><td>&quot;22.39&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.41&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:34:24&quot;</td><td>&quot;38300.00&quot;</td><td>3.65</td><td>139795.0</td><td>-139818.75</td><td>&quot;22.37&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220707</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:17:51&quot;</td><td>&quot;-7580.00&quot;</td><td>2.46</td><td>758000.0</td><td>758357.61</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:357.61实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ str    ┆ str    ┆ str    ┆ str    │\n",
       "│ i64     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022072 ┆ 600269  ┆ 赣粤高  ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 股息入 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 速      ┆        ┆   ┆ \"      ┆ \"      ┆ 账:赣  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 粤高速 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 600269 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ ; 权益 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 股数:4 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 0700;  ┆        │\n",
       "│ 2022071 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券购 ┆ 人民币 │\n",
       "│ 8       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 回:18. ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 63实际 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 占款天 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 数：7- ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 888880 ┆        │\n",
       "│ 2022071 ┆ =\"00246 ┆ 嘉事堂  ┆ 卖出   ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 证券卖 ┆ 人民币 │\n",
       "│ 8       ┆ 2\"      ┆         ┆        ┆   ┆        ┆ \"      ┆ 出     ┆        │\n",
       "│ 2022071 ┆ 600408  ┆ 安泰集  ┆ 买入   ┆ … ┆ 1.51   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 8       ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 600648  ┆ 外高桥  ┆ 买入   ┆ … ┆ 1.49   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 8       ┆         ┆         ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 2022071 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券回 ┆ 人民币 │\n",
       "│ 1       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 购购回 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 日:202 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 20718  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 预计利 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 息:18. ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 63参考 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 占款…  ┆        │\n",
       "│ 2022071 ┆ 601992  ┆ 金隅集  ┆ 买入   ┆ … ┆ 1.42   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 600894  ┆ 广日股  ┆ 买入   ┆ … ┆ 1.41   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 份      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 601077  ┆ 渝农商  ┆ 买入   ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 行      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022070 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券购 ┆ 人民币 │\n",
       "│ 7       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 回:357 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ .61实  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 际占款 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 天数： ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 7-8888 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 80     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "642db9b8-df12-4f69-9bf0-72912bc6effe",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Rows: 17\n",
      "Columns: 16\n",
      "$ 发生日期 <i64> 20220721, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718\n",
      "$ 证券代码 <str> '600269', '204007', '=\"002462\"', '600408', '600648', '600269', '600015', '601992', '600894', '601077'\n",
      "$ 证券名称 <str> '赣粤高速', 'GC007', '嘉事堂', '安泰集团', '外高桥', '赣粤高速', '华夏银行', '金隅集团', '广日股份', '渝农商行'\n",
      "$ 买卖标志 <str> '卖出', '卖出', '卖出', '买入', '买入', '买入', '买入', '卖出', '卖出', '卖出'\n",
      "$ 业务名称 <str> '股息入账', '拆出质押购回', '证券卖出', '证券买入', '证券买入', '证券买入', '证券买入', '证券卖出', '证券卖出', '证券卖出'\n",
      "$ 成交时间 <str> '16:00:00', '19:03:27', '09:38:10', '09:44:52', '09:44:31', '09:43:38', '09:42:51', '09:39:28', '09:39:06', '09:38:30'\n",
      "$ 成交数量 <str> '=\"0.00\"', '-580.00', '-10400.00', '47000.00', '11900.00', '40700.00', '30000.00', '-54000.00', '-21400.00', '-38300.00'\n",
      "$ 成交价格 <f64> 3.6, 1.675, 13.2062, 3.19, 12.6066, 3.69, 5.07, 2.5683, 6.5419, 3.58\n",
      "$ 成交金额 <f64> 4884.0, 58000.0, 137344.0, 149930.0, 150019.0, 150183.0, 152100.0, 138686.0, 139996.0, 137114.0\n",
      "$ 发生金额 <f64> 4884.0, 58018.63, 137184.67, -149955.5, -150044.49, -150208.53, -152125.86, 138523.74, 139832.12, 136953.55\n",
      "$ 手续费  <str> '=\"0.00\"', '=\"0.00\"', '21.98', '23.99', '24.00', '24.03', '24.34', '22.19', '22.40', '21.94'\n",
      "$ 印花税  <str> '=\"0.00\"', '=\"0.00\"', '137.35', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '138.69', '140.02', '137.13'\n",
      "$ 过户费  <str> '=\"0.00\"', '=\"0.00\"', '1.38', '1.51', '1.49', '1.50', '1.52', '1.38', '1.46', '1.38'\n",
      "$ 其他费  <str> '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"'\n",
      "$ 备注   <str> '股息入账:赣粤高速600269; 权益股数:40700;', '融券购回:18.63实际占款天数：7-888880', '证券卖出', '证券买入', '证券买入', '证券买入', '证券买入', '证券卖出', '证券卖出', '证券卖出'\n",
      "$ 币种   <str> '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币'\n",
      "\n"
     ]
    }
   ],
   "source": [
    "df.glimpse()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "53e5c219-72b5-402d-9d68-72e3d6319373",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (5, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220711</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;质押回购拆出&quot;</td><td>&quot;09:39:27&quot;</td><td>&quot;580.00&quot;</td><td>1.675</td><td>58000.0</td><td>-58002.9</td><td>&quot;2.90&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券回购购回日:20220718预计利息:18.63参考占款…</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:37:25&quot;</td><td>&quot;54000.00&quot;</td><td>2.59</td><td>139860.0</td><td>-139883.8</td><td>&quot;22.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.42&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:36:30&quot;</td><td>&quot;21400.00&quot;</td><td>6.54</td><td>139956.0</td><td>-139979.8</td><td>&quot;22.39&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.41&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:34:24&quot;</td><td>&quot;38300.00&quot;</td><td>3.65</td><td>139795.0</td><td>-139818.75</td><td>&quot;22.37&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220707</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:17:51&quot;</td><td>&quot;-7580.00&quot;</td><td>2.46</td><td>758000.0</td><td>758357.61</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:357.61实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (5, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ str    ┆ str    ┆ str    ┆ str    │\n",
       "│ i64     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022071 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券回 ┆ 人民币 │\n",
       "│ 1       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 购购回 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 日:202 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 20718  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 预计利 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 息:18. ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 63参考 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 占款…  ┆        │\n",
       "│ 2022071 ┆ 601992  ┆ 金隅集  ┆ 买入   ┆ … ┆ 1.42   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 600894  ┆ 广日股  ┆ 买入   ┆ … ┆ 1.41   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 份      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 601077  ┆ 渝农商  ┆ 买入   ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 行      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022070 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券购 ┆ 人民币 │\n",
       "│ 7       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 回:357 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ .61实  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 际占款 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 天数： ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 7-8888 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 80     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "75136975-3121-403b-bc32-af094fe87d7b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (5, 5)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th></tr><tr><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;赣粤高速&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:43:38&quot;</td><td>&quot;40700.00&quot;</td></tr><tr><td>&quot;现代投资&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:33:37&quot;</td><td>&quot;34400.00&quot;</td></tr><tr><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:36:30&quot;</td><td>&quot;21400.00&quot;</td></tr><tr><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:31&quot;</td><td>&quot;11900.00&quot;</td></tr><tr><td>&quot;广日股份&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;09:39:06&quot;</td><td>&quot;-21400.00&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (5, 5)\n",
       "┌──────────┬──────────┬──────────┬──────────┬───────────┐\n",
       "│ 证券名称 ┆ 买卖标志 ┆ 业务名称 ┆ 成交时间 ┆ 成交数量  │\n",
       "│ ---      ┆ ---      ┆ ---      ┆ ---      ┆ ---       │\n",
       "│ str      ┆ str      ┆ str      ┆ str      ┆ str       │\n",
       "╞══════════╪══════════╪══════════╪══════════╪═══════════╡\n",
       "│ 赣粤高速 ┆ 买入     ┆ 证券买入 ┆ 09:43:38 ┆ 40700.00  │\n",
       "│ 现代投资 ┆ 买入     ┆ 证券买入 ┆ 09:33:37 ┆ 34400.00  │\n",
       "│ 广日股份 ┆ 买入     ┆ 证券买入 ┆ 09:36:30 ┆ 21400.00  │\n",
       "│ 外高桥   ┆ 买入     ┆ 证券买入 ┆ 09:44:31 ┆ 11900.00  │\n",
       "│ 广日股份 ┆ 卖出     ┆ 证券卖出 ┆ 09:39:06 ┆ -21400.00 │\n",
       "└──────────┴──────────┴──────────┴──────────┴───────────┘"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:,\"证券名称\":\"成交数量\"].sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "cff864ab-e142-4ccf-9d06-e8201d183cef",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (9, 17)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>statistic</th><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>str</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;count&quot;</td><td>17.0</td><td>&quot;17&quot;</td><td>&quot;17&quot;</td><td>&quot;17&quot;</td><td>&quot;17&quot;</td><td>&quot;17&quot;</td><td>&quot;17&quot;</td><td>17.0</td><td>17.0</td><td>17.0</td><td>&quot;17&quot;</td><td>&quot;17&quot;</td><td>&quot;17&quot;</td><td>&quot;17&quot;</td><td>&quot;17&quot;</td><td>&quot;17&quot;</td></tr><tr><td>&quot;null_count&quot;</td><td>0.0</td><td>&quot;0&quot;</td><td>&quot;0&quot;</td><td>&quot;0&quot;</td><td>&quot;0&quot;</td><td>&quot;0&quot;</td><td>&quot;0&quot;</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;0&quot;</td><td>&quot;0&quot;</td><td>&quot;0&quot;</td><td>&quot;0&quot;</td><td>&quot;0&quot;</td><td>&quot;0&quot;</td></tr><tr><td>&quot;mean&quot;</td><td>2.0221e7</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>5.306059</td><td>160805.352941</td><td>815.642353</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;std&quot;</td><td>4.160387</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>3.974618</td><td>159439.770376</td><td>230047.143813</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;min&quot;</td><td>2.0220707e7</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;买入&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;09:33:37&quot;</td><td>&quot;-10400.00&quot;</td><td>1.675</td><td>4884.0</td><td>-152125.86</td><td>&quot;2.90&quot;</td><td>&quot;137.13&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;股息入账:赣粤高速600269; 权益股数:40700;&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&quot;25%&quot;</td><td>2.0220711e7</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>2.59</td><td>137344.0</td><td>-140526.48</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;50%&quot;</td><td>2.0220718e7</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>3.65</td><td>139860.0</td><td>-139342.29</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;75%&quot;</td><td>2.0220718e7</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>6.54</td><td>149930.0</td><td>136953.55</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;max&quot;</td><td>2.0220721e7</td><td>&quot;=&quot;002462&quot;&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;卖出&quot;</td><td>&quot;质押回购拆出&quot;</td><td>&quot;19:17:51&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>13.51</td><td>758000.0</td><td>758357.61</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (9, 17)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ statist ┆ 发生日  ┆ 证券代  ┆ 证券名 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ ic      ┆ 期      ┆ 码      ┆ 称     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ str    ┆ str    ┆ str    ┆ str    │\n",
       "│ str     ┆ f64     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ count   ┆ 17.0    ┆ 17      ┆ 17     ┆ … ┆ 17     ┆ 17     ┆ 17     ┆ 17     │\n",
       "│ null_co ┆ 0.0     ┆ 0       ┆ 0      ┆ … ┆ 0      ┆ 0      ┆ 0      ┆ 0      │\n",
       "│ unt     ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ mean    ┆ 2.0221e ┆ null    ┆ null   ┆ … ┆ null   ┆ null   ┆ null   ┆ null   │\n",
       "│         ┆ 7       ┆         ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ std     ┆ 4.16038 ┆ null    ┆ null   ┆ … ┆ null   ┆ null   ┆ null   ┆ null   │\n",
       "│         ┆ 7       ┆         ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ min     ┆ 2.02207 ┆ 204007  ┆ GC007  ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 股息入 ┆ 人民币 │\n",
       "│         ┆ 07e7    ┆         ┆        ┆   ┆        ┆ \"      ┆ 账:赣  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 粤高速 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 600269 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ ; 权益 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 股数:4 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 0700;  ┆        │\n",
       "│ 25%     ┆ 2.02207 ┆ null    ┆ null   ┆ … ┆ null   ┆ null   ┆ null   ┆ null   │\n",
       "│         ┆ 11e7    ┆         ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ 50%     ┆ 2.02207 ┆ null    ┆ null   ┆ … ┆ null   ┆ null   ┆ null   ┆ null   │\n",
       "│         ┆ 18e7    ┆         ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ 75%     ┆ 2.02207 ┆ null    ┆ null   ┆ … ┆ null   ┆ null   ┆ null   ┆ null   │\n",
       "│         ┆ 18e7    ┆         ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ max     ┆ 2.02207 ┆ =\"00246 ┆ 金隅集 ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 证券卖 ┆ 人民币 │\n",
       "│         ┆ 21e7    ┆ 2\"      ┆ 团     ┆   ┆ \"      ┆ \"      ┆ 出     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "4f8f69c0-a7f6-496f-aaa9-b143efe1e162",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (1, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>u32</td><td>u32</td><td>u32</td><td>u32</td><td>u32</td><td>u32</td><td>u32</td><td>u32</td><td>u32</td><td>u32</td><td>u32</td><td>u32</td><td>u32</td><td>u32</td><td>u32</td><td>u32</td></tr></thead><tbody><tr><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (1, 16)\n",
       "┌──────────┬──────────┬──────────┬─────────┬───┬────────┬────────┬──────┬──────┐\n",
       "│ 发生日期 ┆ 证券代码 ┆ 证券名称 ┆ 买卖标  ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注 ┆ 币种 │\n",
       "│ ---      ┆ ---      ┆ ---      ┆ 志      ┆   ┆ ---    ┆ ---    ┆ ---  ┆ ---  │\n",
       "│ u32      ┆ u32      ┆ u32      ┆ ---     ┆   ┆ u32    ┆ u32    ┆ u32  ┆ u32  │\n",
       "│          ┆          ┆          ┆ u32     ┆   ┆        ┆        ┆      ┆      │\n",
       "╞══════════╪══════════╪══════════╪═════════╪═══╪════════╪════════╪══════╪══════╡\n",
       "│ 0        ┆ 0        ┆ 0        ┆ 0       ┆ … ┆ 0      ┆ 0      ┆ 0    ┆ 0    │\n",
       "└──────────┴──────────┴──────────┴─────────┴───┴────────┴────────┴──────┴──────┘"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.null_count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "69006737-8a44-4574-a63d-d38aeca288dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>发生日期</th>\n",
       "      <th>证券代码</th>\n",
       "      <th>证券名称</th>\n",
       "      <th>买卖标志</th>\n",
       "      <th>业务名称</th>\n",
       "      <th>成交时间</th>\n",
       "      <th>成交数量</th>\n",
       "      <th>成交价格</th>\n",
       "      <th>成交金额</th>\n",
       "      <th>发生金额</th>\n",
       "      <th>手续费</th>\n",
       "      <th>印花税</th>\n",
       "      <th>过户费</th>\n",
       "      <th>其他费</th>\n",
       "      <th>备注</th>\n",
       "      <th>币种</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>20220721</td>\n",
       "      <td>600269</td>\n",
       "      <td>赣粤高速</td>\n",
       "      <td>卖出</td>\n",
       "      <td>股息入账</td>\n",
       "      <td>16:00:00</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>3.6000</td>\n",
       "      <td>4884.0</td>\n",
       "      <td>4884.00</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>股息入账:赣粤高速600269; 权益股数:40700;</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20220718</td>\n",
       "      <td>204007</td>\n",
       "      <td>GC007</td>\n",
       "      <td>卖出</td>\n",
       "      <td>拆出质押购回</td>\n",
       "      <td>19:03:27</td>\n",
       "      <td>-580.00</td>\n",
       "      <td>1.6750</td>\n",
       "      <td>58000.0</td>\n",
       "      <td>58018.63</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>融券购回:18.63实际占款天数：7-888880</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>20220718</td>\n",
       "      <td>=\"002462\"</td>\n",
       "      <td>嘉事堂</td>\n",
       "      <td>卖出</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>09:38:10</td>\n",
       "      <td>-10400.00</td>\n",
       "      <td>13.2062</td>\n",
       "      <td>137344.0</td>\n",
       "      <td>137184.67</td>\n",
       "      <td>21.98</td>\n",
       "      <td>137.35</td>\n",
       "      <td>1.38</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>20220718</td>\n",
       "      <td>600408</td>\n",
       "      <td>安泰集团</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:44:52</td>\n",
       "      <td>47000.00</td>\n",
       "      <td>3.1900</td>\n",
       "      <td>149930.0</td>\n",
       "      <td>-149955.50</td>\n",
       "      <td>23.99</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.51</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>20220718</td>\n",
       "      <td>600648</td>\n",
       "      <td>外高桥</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:44:31</td>\n",
       "      <td>11900.00</td>\n",
       "      <td>12.6066</td>\n",
       "      <td>150019.0</td>\n",
       "      <td>-150044.49</td>\n",
       "      <td>24.00</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.49</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>20220718</td>\n",
       "      <td>600269</td>\n",
       "      <td>赣粤高速</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:43:38</td>\n",
       "      <td>40700.00</td>\n",
       "      <td>3.6900</td>\n",
       "      <td>150183.0</td>\n",
       "      <td>-150208.53</td>\n",
       "      <td>24.03</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.50</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>20220718</td>\n",
       "      <td>600015</td>\n",
       "      <td>华夏银行</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:42:51</td>\n",
       "      <td>30000.00</td>\n",
       "      <td>5.0700</td>\n",
       "      <td>152100.0</td>\n",
       "      <td>-152125.86</td>\n",
       "      <td>24.34</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.52</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>20220718</td>\n",
       "      <td>601992</td>\n",
       "      <td>金隅集团</td>\n",
       "      <td>卖出</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>09:39:28</td>\n",
       "      <td>-54000.00</td>\n",
       "      <td>2.5683</td>\n",
       "      <td>138686.0</td>\n",
       "      <td>138523.74</td>\n",
       "      <td>22.19</td>\n",
       "      <td>138.69</td>\n",
       "      <td>1.38</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>20220718</td>\n",
       "      <td>600894</td>\n",
       "      <td>广日股份</td>\n",
       "      <td>卖出</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>09:39:06</td>\n",
       "      <td>-21400.00</td>\n",
       "      <td>6.5419</td>\n",
       "      <td>139996.0</td>\n",
       "      <td>139832.12</td>\n",
       "      <td>22.40</td>\n",
       "      <td>140.02</td>\n",
       "      <td>1.46</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>20220718</td>\n",
       "      <td>601077</td>\n",
       "      <td>渝农商行</td>\n",
       "      <td>卖出</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>09:38:30</td>\n",
       "      <td>-38300.00</td>\n",
       "      <td>3.5800</td>\n",
       "      <td>137114.0</td>\n",
       "      <td>136953.55</td>\n",
       "      <td>21.94</td>\n",
       "      <td>137.13</td>\n",
       "      <td>1.38</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>20220711</td>\n",
       "      <td>=\"002462\"</td>\n",
       "      <td>嘉事堂</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:38:16</td>\n",
       "      <td>10400.00</td>\n",
       "      <td>13.5100</td>\n",
       "      <td>140504.0</td>\n",
       "      <td>-140526.48</td>\n",
       "      <td>22.48</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.41</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>20220711</td>\n",
       "      <td>=\"000900\"</td>\n",
       "      <td>现代投资</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:33:37</td>\n",
       "      <td>34400.00</td>\n",
       "      <td>4.0500</td>\n",
       "      <td>139320.0</td>\n",
       "      <td>-139342.29</td>\n",
       "      <td>22.29</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.39</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>20220711</td>\n",
       "      <td>204007</td>\n",
       "      <td>GC007</td>\n",
       "      <td>卖出</td>\n",
       "      <td>质押回购拆出</td>\n",
       "      <td>09:39:27</td>\n",
       "      <td>580.00</td>\n",
       "      <td>1.6750</td>\n",
       "      <td>58000.0</td>\n",
       "      <td>-58002.90</td>\n",
       "      <td>2.90</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>融券回购购回日:20220718预计利息:18.63参考占款天数：7-888880</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>20220711</td>\n",
       "      <td>601992</td>\n",
       "      <td>金隅集团</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:37:25</td>\n",
       "      <td>54000.00</td>\n",
       "      <td>2.5900</td>\n",
       "      <td>139860.0</td>\n",
       "      <td>-139883.80</td>\n",
       "      <td>22.38</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.42</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>20220711</td>\n",
       "      <td>600894</td>\n",
       "      <td>广日股份</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:36:30</td>\n",
       "      <td>21400.00</td>\n",
       "      <td>6.5400</td>\n",
       "      <td>139956.0</td>\n",
       "      <td>-139979.80</td>\n",
       "      <td>22.39</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.41</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>20220711</td>\n",
       "      <td>601077</td>\n",
       "      <td>渝农商行</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:34:24</td>\n",
       "      <td>38300.00</td>\n",
       "      <td>3.6500</td>\n",
       "      <td>139795.0</td>\n",
       "      <td>-139818.75</td>\n",
       "      <td>22.37</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.38</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>20220707</td>\n",
       "      <td>204007</td>\n",
       "      <td>GC007</td>\n",
       "      <td>卖出</td>\n",
       "      <td>拆出质押购回</td>\n",
       "      <td>19:17:51</td>\n",
       "      <td>-7580.00</td>\n",
       "      <td>2.4600</td>\n",
       "      <td>758000.0</td>\n",
       "      <td>758357.61</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>融券购回:357.61实际占款天数：7-888880</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        发生日期       证券代码   证券名称 买卖标志    业务名称      成交时间       成交数量     成交价格  \\\n",
       "0   20220721     600269   赣粤高速   卖出    股息入账  16:00:00    =\"0.00\"   3.6000   \n",
       "1   20220718     204007  GC007   卖出  拆出质押购回  19:03:27    -580.00   1.6750   \n",
       "2   20220718  =\"002462\"    嘉事堂   卖出    证券卖出  09:38:10  -10400.00  13.2062   \n",
       "3   20220718     600408   安泰集团   买入    证券买入  09:44:52   47000.00   3.1900   \n",
       "4   20220718     600648    外高桥   买入    证券买入  09:44:31   11900.00  12.6066   \n",
       "5   20220718     600269   赣粤高速   买入    证券买入  09:43:38   40700.00   3.6900   \n",
       "6   20220718     600015   华夏银行   买入    证券买入  09:42:51   30000.00   5.0700   \n",
       "7   20220718     601992   金隅集团   卖出    证券卖出  09:39:28  -54000.00   2.5683   \n",
       "8   20220718     600894   广日股份   卖出    证券卖出  09:39:06  -21400.00   6.5419   \n",
       "9   20220718     601077   渝农商行   卖出    证券卖出  09:38:30  -38300.00   3.5800   \n",
       "10  20220711  =\"002462\"    嘉事堂   买入    证券买入  09:38:16   10400.00  13.5100   \n",
       "11  20220711  =\"000900\"   现代投资   买入    证券买入  09:33:37   34400.00   4.0500   \n",
       "12  20220711     204007  GC007   卖出  质押回购拆出  09:39:27     580.00   1.6750   \n",
       "13  20220711     601992   金隅集团   买入    证券买入  09:37:25   54000.00   2.5900   \n",
       "14  20220711     600894   广日股份   买入    证券买入  09:36:30   21400.00   6.5400   \n",
       "15  20220711     601077   渝农商行   买入    证券买入  09:34:24   38300.00   3.6500   \n",
       "16  20220707     204007  GC007   卖出  拆出质押购回  19:17:51   -7580.00   2.4600   \n",
       "\n",
       "        成交金额       发生金额      手续费      印花税      过户费      其他费  \\\n",
       "0     4884.0    4884.00  =\"0.00\"  =\"0.00\"  =\"0.00\"  =\"0.00\"   \n",
       "1    58000.0   58018.63  =\"0.00\"  =\"0.00\"  =\"0.00\"  =\"0.00\"   \n",
       "2   137344.0  137184.67    21.98   137.35     1.38  =\"0.00\"   \n",
       "3   149930.0 -149955.50    23.99  =\"0.00\"     1.51  =\"0.00\"   \n",
       "4   150019.0 -150044.49    24.00  =\"0.00\"     1.49  =\"0.00\"   \n",
       "5   150183.0 -150208.53    24.03  =\"0.00\"     1.50  =\"0.00\"   \n",
       "6   152100.0 -152125.86    24.34  =\"0.00\"     1.52  =\"0.00\"   \n",
       "7   138686.0  138523.74    22.19   138.69     1.38  =\"0.00\"   \n",
       "8   139996.0  139832.12    22.40   140.02     1.46  =\"0.00\"   \n",
       "9   137114.0  136953.55    21.94   137.13     1.38  =\"0.00\"   \n",
       "10  140504.0 -140526.48    22.48  =\"0.00\"     1.41  =\"0.00\"   \n",
       "11  139320.0 -139342.29    22.29  =\"0.00\"     1.39  =\"0.00\"   \n",
       "12   58000.0  -58002.90     2.90  =\"0.00\"  =\"0.00\"  =\"0.00\"   \n",
       "13  139860.0 -139883.80    22.38  =\"0.00\"     1.42  =\"0.00\"   \n",
       "14  139956.0 -139979.80    22.39  =\"0.00\"     1.41  =\"0.00\"   \n",
       "15  139795.0 -139818.75    22.37  =\"0.00\"     1.38  =\"0.00\"   \n",
       "16  758000.0  758357.61  =\"0.00\"  =\"0.00\"  =\"0.00\"  =\"0.00\"   \n",
       "\n",
       "                                           备注   币种  \n",
       "0                股息入账:赣粤高速600269; 权益股数:40700;  人民币  \n",
       "1                   融券购回:18.63实际占款天数：7-888880  人民币  \n",
       "2                                        证券卖出  人民币  \n",
       "3                                        证券买入  人民币  \n",
       "4                                        证券买入  人民币  \n",
       "5                                        证券买入  人民币  \n",
       "6                                        证券买入  人民币  \n",
       "7                                        证券卖出  人民币  \n",
       "8                                        证券卖出  人民币  \n",
       "9                                        证券卖出  人民币  \n",
       "10                                       证券买入  人民币  \n",
       "11                                       证券买入  人民币  \n",
       "12  融券回购购回日:20220718预计利息:18.63参考占款天数：7-888880  人民币  \n",
       "13                                       证券买入  人民币  \n",
       "14                                       证券买入  人民币  \n",
       "15                                       证券买入  人民币  \n",
       "16                 融券购回:357.61实际占款天数：7-888880  人民币  "
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_pandas()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "9a6f709e-e72a-4093-99a0-08d76b24f94c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(df.to_pandas())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "65741d14-ac2c-4638-89a6-9cb4b23216e1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pyarrow.Table\n",
       "发生日期: int64\n",
       "证券代码: large_string\n",
       "证券名称: large_string\n",
       "买卖标志: large_string\n",
       "业务名称: large_string\n",
       "成交时间: large_string\n",
       "成交数量: large_string\n",
       "成交价格: double\n",
       "成交金额: double\n",
       "发生金额: double\n",
       "手续费: large_string\n",
       "印花税: large_string\n",
       "过户费: large_string\n",
       "其他费: large_string\n",
       "备注: large_string\n",
       "币种: large_string\n",
       "----\n",
       "发生日期: [[20220721,20220718,20220718,20220718,20220718,...,20220711,20220711,20220711,20220711,20220707]]\n",
       "证券代码: [[\"600269\",\"204007\",\"=\"002462\"\",\"600408\",\"600648\",...,\"204007\",\"601992\",\"600894\",\"601077\",\"204007\"]]\n",
       "证券名称: [[\"赣粤高速\",\"GC007\",\"嘉事堂\",\"安泰集团\",\"外高桥\",...,\"GC007\",\"金隅集团\",\"广日股份\",\"渝农商行\",\"GC007\"]]\n",
       "买卖标志: [[\"卖出\",\"卖出\",\"卖出\",\"买入\",\"买入\",...,\"卖出\",\"买入\",\"买入\",\"买入\",\"卖出\"]]\n",
       "业务名称: [[\"股息入账\",\"拆出质押购回\",\"证券卖出\",\"证券买入\",\"证券买入\",...,\"质押回购拆出\",\"证券买入\",\"证券买入\",\"证券买入\",\"拆出质押购回\"]]\n",
       "成交时间: [[\"16:00:00\",\"19:03:27\",\"09:38:10\",\"09:44:52\",\"09:44:31\",...,\"09:39:27\",\"09:37:25\",\"09:36:30\",\"09:34:24\",\"19:17:51\"]]\n",
       "成交数量: [[\"=\"0.00\"\",\"-580.00\",\"-10400.00\",\"47000.00\",\"11900.00\",...,\"580.00\",\"54000.00\",\"21400.00\",\"38300.00\",\"-7580.00\"]]\n",
       "成交价格: [[3.6,1.675,13.2062,3.19,12.6066,...,1.675,2.59,6.54,3.65,2.46]]\n",
       "成交金额: [[4884,58000,137344,149930,150019,...,58000,139860,139956,139795,758000]]\n",
       "发生金额: [[4884,58018.63,137184.67,-149955.5,-150044.49,...,-58002.9,-139883.8,-139979.8,-139818.75,758357.61]]\n",
       "..."
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_arrow()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "dbb00815-6bf2-4d78-9078-cd674e272a82",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'发生日期': 20220721,\n",
       "  '证券代码': '600269',\n",
       "  '证券名称': '赣粤高速',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '股息入账',\n",
       "  '成交时间': '16:00:00',\n",
       "  '成交数量': '=\"0.00\"',\n",
       "  '成交价格': 3.6,\n",
       "  '成交金额': 4884.0,\n",
       "  '发生金额': 4884.0,\n",
       "  '手续费': '=\"0.00\"',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '=\"0.00\"',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '股息入账:赣粤高速600269; 权益股数:40700;',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '204007',\n",
       "  '证券名称': 'GC007',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '拆出质押购回',\n",
       "  '成交时间': '19:03:27',\n",
       "  '成交数量': '-580.00',\n",
       "  '成交价格': 1.675,\n",
       "  '成交金额': 58000.0,\n",
       "  '发生金额': 58018.63,\n",
       "  '手续费': '=\"0.00\"',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '=\"0.00\"',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '融券购回:18.63实际占款天数：7-888880',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '=\"002462\"',\n",
       "  '证券名称': '嘉事堂',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '证券卖出',\n",
       "  '成交时间': '09:38:10',\n",
       "  '成交数量': '-10400.00',\n",
       "  '成交价格': 13.2062,\n",
       "  '成交金额': 137344.0,\n",
       "  '发生金额': 137184.67,\n",
       "  '手续费': '21.98',\n",
       "  '印花税': '137.35',\n",
       "  '过户费': '1.38',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券卖出',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600408',\n",
       "  '证券名称': '安泰集团',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:44:52',\n",
       "  '成交数量': '47000.00',\n",
       "  '成交价格': 3.19,\n",
       "  '成交金额': 149930.0,\n",
       "  '发生金额': -149955.5,\n",
       "  '手续费': '23.99',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.51',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600648',\n",
       "  '证券名称': '外高桥',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:44:31',\n",
       "  '成交数量': '11900.00',\n",
       "  '成交价格': 12.6066,\n",
       "  '成交金额': 150019.0,\n",
       "  '发生金额': -150044.49,\n",
       "  '手续费': '24.00',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.49',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600269',\n",
       "  '证券名称': '赣粤高速',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:43:38',\n",
       "  '成交数量': '40700.00',\n",
       "  '成交价格': 3.69,\n",
       "  '成交金额': 150183.0,\n",
       "  '发生金额': -150208.53,\n",
       "  '手续费': '24.03',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.50',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600015',\n",
       "  '证券名称': '华夏银行',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:42:51',\n",
       "  '成交数量': '30000.00',\n",
       "  '成交价格': 5.07,\n",
       "  '成交金额': 152100.0,\n",
       "  '发生金额': -152125.86,\n",
       "  '手续费': '24.34',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.52',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '601992',\n",
       "  '证券名称': '金隅集团',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '证券卖出',\n",
       "  '成交时间': '09:39:28',\n",
       "  '成交数量': '-54000.00',\n",
       "  '成交价格': 2.5683,\n",
       "  '成交金额': 138686.0,\n",
       "  '发生金额': 138523.74,\n",
       "  '手续费': '22.19',\n",
       "  '印花税': '138.69',\n",
       "  '过户费': '1.38',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券卖出',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600894',\n",
       "  '证券名称': '广日股份',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '证券卖出',\n",
       "  '成交时间': '09:39:06',\n",
       "  '成交数量': '-21400.00',\n",
       "  '成交价格': 6.5419,\n",
       "  '成交金额': 139996.0,\n",
       "  '发生金额': 139832.12,\n",
       "  '手续费': '22.40',\n",
       "  '印花税': '140.02',\n",
       "  '过户费': '1.46',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券卖出',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '601077',\n",
       "  '证券名称': '渝农商行',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '证券卖出',\n",
       "  '成交时间': '09:38:30',\n",
       "  '成交数量': '-38300.00',\n",
       "  '成交价格': 3.58,\n",
       "  '成交金额': 137114.0,\n",
       "  '发生金额': 136953.55,\n",
       "  '手续费': '21.94',\n",
       "  '印花税': '137.13',\n",
       "  '过户费': '1.38',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券卖出',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '=\"002462\"',\n",
       "  '证券名称': '嘉事堂',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:38:16',\n",
       "  '成交数量': '10400.00',\n",
       "  '成交价格': 13.51,\n",
       "  '成交金额': 140504.0,\n",
       "  '发生金额': -140526.48,\n",
       "  '手续费': '22.48',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.41',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '=\"000900\"',\n",
       "  '证券名称': '现代投资',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:33:37',\n",
       "  '成交数量': '34400.00',\n",
       "  '成交价格': 4.05,\n",
       "  '成交金额': 139320.0,\n",
       "  '发生金额': -139342.29,\n",
       "  '手续费': '22.29',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.39',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '204007',\n",
       "  '证券名称': 'GC007',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '质押回购拆出',\n",
       "  '成交时间': '09:39:27',\n",
       "  '成交数量': '580.00',\n",
       "  '成交价格': 1.675,\n",
       "  '成交金额': 58000.0,\n",
       "  '发生金额': -58002.9,\n",
       "  '手续费': '2.90',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '=\"0.00\"',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '融券回购购回日:20220718预计利息:18.63参考占款天数：7-888880',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '601992',\n",
       "  '证券名称': '金隅集团',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:37:25',\n",
       "  '成交数量': '54000.00',\n",
       "  '成交价格': 2.59,\n",
       "  '成交金额': 139860.0,\n",
       "  '发生金额': -139883.8,\n",
       "  '手续费': '22.38',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.42',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '600894',\n",
       "  '证券名称': '广日股份',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:36:30',\n",
       "  '成交数量': '21400.00',\n",
       "  '成交价格': 6.54,\n",
       "  '成交金额': 139956.0,\n",
       "  '发生金额': -139979.8,\n",
       "  '手续费': '22.39',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.41',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '601077',\n",
       "  '证券名称': '渝农商行',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:34:24',\n",
       "  '成交数量': '38300.00',\n",
       "  '成交价格': 3.65,\n",
       "  '成交金额': 139795.0,\n",
       "  '发生金额': -139818.75,\n",
       "  '手续费': '22.37',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.38',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220707,\n",
       "  '证券代码': '204007',\n",
       "  '证券名称': 'GC007',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '拆出质押购回',\n",
       "  '成交时间': '19:17:51',\n",
       "  '成交数量': '-7580.00',\n",
       "  '成交价格': 2.46,\n",
       "  '成交金额': 758000.0,\n",
       "  '发生金额': 758357.61,\n",
       "  '手续费': '=\"0.00\"',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '=\"0.00\"',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '融券购回:357.61实际占款天数：7-888880',\n",
       "  '币种': '人民币'}]"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_dicts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "f90f2df5-258b-4d92-97d2-c7c0ccbce52e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(20220721,\n",
       "  '600269',\n",
       "  '赣粤高速',\n",
       "  '卖出',\n",
       "  '股息入账',\n",
       "  '16:00:00',\n",
       "  '=\"0.00\"',\n",
       "  3.6,\n",
       "  4884.0,\n",
       "  4884.0,\n",
       "  '=\"0.00\"',\n",
       "  '=\"0.00\"',\n",
       "  '=\"0.00\"',\n",
       "  '=\"0.00\"',\n",
       "  '股息入账:赣粤高速600269; 权益股数:40700;',\n",
       "  '人民币'),\n",
       " (20220718,\n",
       "  '204007',\n",
       "  'GC007',\n",
       "  '卖出',\n",
       "  '拆出质押购回',\n",
       "  '19:03:27',\n",
       "  '-580.00',\n",
       "  1.675,\n",
       "  58000.0,\n",
       "  58018.63,\n",
       "  '=\"0.00\"',\n",
       "  '=\"0.00\"',\n",
       "  '=\"0.00\"',\n",
       "  '=\"0.00\"',\n",
       "  '融券购回:18.63实际占款天数：7-888880',\n",
       "  '人民币'),\n",
       " (20220718,\n",
       "  '=\"002462\"',\n",
       "  '嘉事堂',\n",
       "  '卖出',\n",
       "  '证券卖出',\n",
       "  '09:38:10',\n",
       "  '-10400.00',\n",
       "  13.2062,\n",
       "  137344.0,\n",
       "  137184.67,\n",
       "  '21.98',\n",
       "  '137.35',\n",
       "  '1.38',\n",
       "  '=\"0.00\"',\n",
       "  '证券卖出',\n",
       "  '人民币'),\n",
       " (20220718,\n",
       "  '600408',\n",
       "  '安泰集团',\n",
       "  '买入',\n",
       "  '证券买入',\n",
       "  '09:44:52',\n",
       "  '47000.00',\n",
       "  3.19,\n",
       "  149930.0,\n",
       "  -149955.5,\n",
       "  '23.99',\n",
       "  '=\"0.00\"',\n",
       "  '1.51',\n",
       "  '=\"0.00\"',\n",
       "  '证券买入',\n",
       "  '人民币'),\n",
       " (20220718,\n",
       "  '600648',\n",
       "  '外高桥',\n",
       "  '买入',\n",
       "  '证券买入',\n",
       "  '09:44:31',\n",
       "  '11900.00',\n",
       "  12.6066,\n",
       "  150019.0,\n",
       "  -150044.49,\n",
       "  '24.00',\n",
       "  '=\"0.00\"',\n",
       "  '1.49',\n",
       "  '=\"0.00\"',\n",
       "  '证券买入',\n",
       "  '人民币'),\n",
       " (20220718,\n",
       "  '600269',\n",
       "  '赣粤高速',\n",
       "  '买入',\n",
       "  '证券买入',\n",
       "  '09:43:38',\n",
       "  '40700.00',\n",
       "  3.69,\n",
       "  150183.0,\n",
       "  -150208.53,\n",
       "  '24.03',\n",
       "  '=\"0.00\"',\n",
       "  '1.50',\n",
       "  '=\"0.00\"',\n",
       "  '证券买入',\n",
       "  '人民币'),\n",
       " (20220718,\n",
       "  '600015',\n",
       "  '华夏银行',\n",
       "  '买入',\n",
       "  '证券买入',\n",
       "  '09:42:51',\n",
       "  '30000.00',\n",
       "  5.07,\n",
       "  152100.0,\n",
       "  -152125.86,\n",
       "  '24.34',\n",
       "  '=\"0.00\"',\n",
       "  '1.52',\n",
       "  '=\"0.00\"',\n",
       "  '证券买入',\n",
       "  '人民币'),\n",
       " (20220718,\n",
       "  '601992',\n",
       "  '金隅集团',\n",
       "  '卖出',\n",
       "  '证券卖出',\n",
       "  '09:39:28',\n",
       "  '-54000.00',\n",
       "  2.5683,\n",
       "  138686.0,\n",
       "  138523.74,\n",
       "  '22.19',\n",
       "  '138.69',\n",
       "  '1.38',\n",
       "  '=\"0.00\"',\n",
       "  '证券卖出',\n",
       "  '人民币'),\n",
       " (20220718,\n",
       "  '600894',\n",
       "  '广日股份',\n",
       "  '卖出',\n",
       "  '证券卖出',\n",
       "  '09:39:06',\n",
       "  '-21400.00',\n",
       "  6.5419,\n",
       "  139996.0,\n",
       "  139832.12,\n",
       "  '22.40',\n",
       "  '140.02',\n",
       "  '1.46',\n",
       "  '=\"0.00\"',\n",
       "  '证券卖出',\n",
       "  '人民币'),\n",
       " (20220718,\n",
       "  '601077',\n",
       "  '渝农商行',\n",
       "  '卖出',\n",
       "  '证券卖出',\n",
       "  '09:38:30',\n",
       "  '-38300.00',\n",
       "  3.58,\n",
       "  137114.0,\n",
       "  136953.55,\n",
       "  '21.94',\n",
       "  '137.13',\n",
       "  '1.38',\n",
       "  '=\"0.00\"',\n",
       "  '证券卖出',\n",
       "  '人民币'),\n",
       " (20220711,\n",
       "  '=\"002462\"',\n",
       "  '嘉事堂',\n",
       "  '买入',\n",
       "  '证券买入',\n",
       "  '09:38:16',\n",
       "  '10400.00',\n",
       "  13.51,\n",
       "  140504.0,\n",
       "  -140526.48,\n",
       "  '22.48',\n",
       "  '=\"0.00\"',\n",
       "  '1.41',\n",
       "  '=\"0.00\"',\n",
       "  '证券买入',\n",
       "  '人民币'),\n",
       " (20220711,\n",
       "  '=\"000900\"',\n",
       "  '现代投资',\n",
       "  '买入',\n",
       "  '证券买入',\n",
       "  '09:33:37',\n",
       "  '34400.00',\n",
       "  4.05,\n",
       "  139320.0,\n",
       "  -139342.29,\n",
       "  '22.29',\n",
       "  '=\"0.00\"',\n",
       "  '1.39',\n",
       "  '=\"0.00\"',\n",
       "  '证券买入',\n",
       "  '人民币'),\n",
       " (20220711,\n",
       "  '204007',\n",
       "  'GC007',\n",
       "  '卖出',\n",
       "  '质押回购拆出',\n",
       "  '09:39:27',\n",
       "  '580.00',\n",
       "  1.675,\n",
       "  58000.0,\n",
       "  -58002.9,\n",
       "  '2.90',\n",
       "  '=\"0.00\"',\n",
       "  '=\"0.00\"',\n",
       "  '=\"0.00\"',\n",
       "  '融券回购购回日:20220718预计利息:18.63参考占款天数：7-888880',\n",
       "  '人民币'),\n",
       " (20220711,\n",
       "  '601992',\n",
       "  '金隅集团',\n",
       "  '买入',\n",
       "  '证券买入',\n",
       "  '09:37:25',\n",
       "  '54000.00',\n",
       "  2.59,\n",
       "  139860.0,\n",
       "  -139883.8,\n",
       "  '22.38',\n",
       "  '=\"0.00\"',\n",
       "  '1.42',\n",
       "  '=\"0.00\"',\n",
       "  '证券买入',\n",
       "  '人民币'),\n",
       " (20220711,\n",
       "  '600894',\n",
       "  '广日股份',\n",
       "  '买入',\n",
       "  '证券买入',\n",
       "  '09:36:30',\n",
       "  '21400.00',\n",
       "  6.54,\n",
       "  139956.0,\n",
       "  -139979.8,\n",
       "  '22.39',\n",
       "  '=\"0.00\"',\n",
       "  '1.41',\n",
       "  '=\"0.00\"',\n",
       "  '证券买入',\n",
       "  '人民币'),\n",
       " (20220711,\n",
       "  '601077',\n",
       "  '渝农商行',\n",
       "  '买入',\n",
       "  '证券买入',\n",
       "  '09:34:24',\n",
       "  '38300.00',\n",
       "  3.65,\n",
       "  139795.0,\n",
       "  -139818.75,\n",
       "  '22.37',\n",
       "  '=\"0.00\"',\n",
       "  '1.38',\n",
       "  '=\"0.00\"',\n",
       "  '证券买入',\n",
       "  '人民币'),\n",
       " (20220707,\n",
       "  '204007',\n",
       "  'GC007',\n",
       "  '卖出',\n",
       "  '拆出质押购回',\n",
       "  '19:17:51',\n",
       "  '-7580.00',\n",
       "  2.46,\n",
       "  758000.0,\n",
       "  758357.61,\n",
       "  '=\"0.00\"',\n",
       "  '=\"0.00\"',\n",
       "  '=\"0.00\"',\n",
       "  '=\"0.00\"',\n",
       "  '融券购回:357.61实际占款天数：7-888880',\n",
       "  '人民币')]"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.rows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "25d818b9-1d63-4550-a01c-a46a7063257a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'发生日期': 20220721,\n",
       "  '证券代码': '600269',\n",
       "  '证券名称': '赣粤高速',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '股息入账',\n",
       "  '成交时间': '16:00:00',\n",
       "  '成交数量': '=\"0.00\"',\n",
       "  '成交价格': 3.6,\n",
       "  '成交金额': 4884.0,\n",
       "  '发生金额': 4884.0,\n",
       "  '手续费': '=\"0.00\"',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '=\"0.00\"',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '股息入账:赣粤高速600269; 权益股数:40700;',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '204007',\n",
       "  '证券名称': 'GC007',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '拆出质押购回',\n",
       "  '成交时间': '19:03:27',\n",
       "  '成交数量': '-580.00',\n",
       "  '成交价格': 1.675,\n",
       "  '成交金额': 58000.0,\n",
       "  '发生金额': 58018.63,\n",
       "  '手续费': '=\"0.00\"',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '=\"0.00\"',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '融券购回:18.63实际占款天数：7-888880',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '=\"002462\"',\n",
       "  '证券名称': '嘉事堂',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '证券卖出',\n",
       "  '成交时间': '09:38:10',\n",
       "  '成交数量': '-10400.00',\n",
       "  '成交价格': 13.2062,\n",
       "  '成交金额': 137344.0,\n",
       "  '发生金额': 137184.67,\n",
       "  '手续费': '21.98',\n",
       "  '印花税': '137.35',\n",
       "  '过户费': '1.38',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券卖出',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600408',\n",
       "  '证券名称': '安泰集团',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:44:52',\n",
       "  '成交数量': '47000.00',\n",
       "  '成交价格': 3.19,\n",
       "  '成交金额': 149930.0,\n",
       "  '发生金额': -149955.5,\n",
       "  '手续费': '23.99',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.51',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600648',\n",
       "  '证券名称': '外高桥',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:44:31',\n",
       "  '成交数量': '11900.00',\n",
       "  '成交价格': 12.6066,\n",
       "  '成交金额': 150019.0,\n",
       "  '发生金额': -150044.49,\n",
       "  '手续费': '24.00',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.49',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600269',\n",
       "  '证券名称': '赣粤高速',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:43:38',\n",
       "  '成交数量': '40700.00',\n",
       "  '成交价格': 3.69,\n",
       "  '成交金额': 150183.0,\n",
       "  '发生金额': -150208.53,\n",
       "  '手续费': '24.03',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.50',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600015',\n",
       "  '证券名称': '华夏银行',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:42:51',\n",
       "  '成交数量': '30000.00',\n",
       "  '成交价格': 5.07,\n",
       "  '成交金额': 152100.0,\n",
       "  '发生金额': -152125.86,\n",
       "  '手续费': '24.34',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.52',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '601992',\n",
       "  '证券名称': '金隅集团',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '证券卖出',\n",
       "  '成交时间': '09:39:28',\n",
       "  '成交数量': '-54000.00',\n",
       "  '成交价格': 2.5683,\n",
       "  '成交金额': 138686.0,\n",
       "  '发生金额': 138523.74,\n",
       "  '手续费': '22.19',\n",
       "  '印花税': '138.69',\n",
       "  '过户费': '1.38',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券卖出',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600894',\n",
       "  '证券名称': '广日股份',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '证券卖出',\n",
       "  '成交时间': '09:39:06',\n",
       "  '成交数量': '-21400.00',\n",
       "  '成交价格': 6.5419,\n",
       "  '成交金额': 139996.0,\n",
       "  '发生金额': 139832.12,\n",
       "  '手续费': '22.40',\n",
       "  '印花税': '140.02',\n",
       "  '过户费': '1.46',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券卖出',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '601077',\n",
       "  '证券名称': '渝农商行',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '证券卖出',\n",
       "  '成交时间': '09:38:30',\n",
       "  '成交数量': '-38300.00',\n",
       "  '成交价格': 3.58,\n",
       "  '成交金额': 137114.0,\n",
       "  '发生金额': 136953.55,\n",
       "  '手续费': '21.94',\n",
       "  '印花税': '137.13',\n",
       "  '过户费': '1.38',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券卖出',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '=\"002462\"',\n",
       "  '证券名称': '嘉事堂',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:38:16',\n",
       "  '成交数量': '10400.00',\n",
       "  '成交价格': 13.51,\n",
       "  '成交金额': 140504.0,\n",
       "  '发生金额': -140526.48,\n",
       "  '手续费': '22.48',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.41',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '=\"000900\"',\n",
       "  '证券名称': '现代投资',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:33:37',\n",
       "  '成交数量': '34400.00',\n",
       "  '成交价格': 4.05,\n",
       "  '成交金额': 139320.0,\n",
       "  '发生金额': -139342.29,\n",
       "  '手续费': '22.29',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.39',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '204007',\n",
       "  '证券名称': 'GC007',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '质押回购拆出',\n",
       "  '成交时间': '09:39:27',\n",
       "  '成交数量': '580.00',\n",
       "  '成交价格': 1.675,\n",
       "  '成交金额': 58000.0,\n",
       "  '发生金额': -58002.9,\n",
       "  '手续费': '2.90',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '=\"0.00\"',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '融券回购购回日:20220718预计利息:18.63参考占款天数：7-888880',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '601992',\n",
       "  '证券名称': '金隅集团',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:37:25',\n",
       "  '成交数量': '54000.00',\n",
       "  '成交价格': 2.59,\n",
       "  '成交金额': 139860.0,\n",
       "  '发生金额': -139883.8,\n",
       "  '手续费': '22.38',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.42',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '600894',\n",
       "  '证券名称': '广日股份',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:36:30',\n",
       "  '成交数量': '21400.00',\n",
       "  '成交价格': 6.54,\n",
       "  '成交金额': 139956.0,\n",
       "  '发生金额': -139979.8,\n",
       "  '手续费': '22.39',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.41',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '601077',\n",
       "  '证券名称': '渝农商行',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:34:24',\n",
       "  '成交数量': '38300.00',\n",
       "  '成交价格': 3.65,\n",
       "  '成交金额': 139795.0,\n",
       "  '发生金额': -139818.75,\n",
       "  '手续费': '22.37',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.38',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220707,\n",
       "  '证券代码': '204007',\n",
       "  '证券名称': 'GC007',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '拆出质押购回',\n",
       "  '成交时间': '19:17:51',\n",
       "  '成交数量': '-7580.00',\n",
       "  '成交价格': 2.46,\n",
       "  '成交金额': 758000.0,\n",
       "  '发生金额': 758357.61,\n",
       "  '手续费': '=\"0.00\"',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '=\"0.00\"',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '融券购回:357.61实际占款天数：7-888880',\n",
       "  '币种': '人民币'}]"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_dicts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c23d6b56-bc3f-4dbc-9d73-f8025bb73c24",
   "metadata": {},
   "outputs": [],
   "source": [
    "import polars as pl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6f2ffbc6-9862-453c-85bb-2b99db5f5529",
   "metadata": {},
   "outputs": [],
   "source": [
    "df=pl.read_csv(\"stock_trades/202207-湘财.xls\",encoding=\"gb18030\",separator=\"\\t\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f4b0b7cc-c9a7-4884-86ec-c5e4dd106432",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17,)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th></tr><tr><td>i64</td></tr></thead><tbody><tr><td>20220721</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>&hellip;</td></tr><tr><td>20220711</td></tr><tr><td>20220711</td></tr><tr><td>20220711</td></tr><tr><td>20220711</td></tr><tr><td>20220707</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17,)\n",
       "Series: '发生日期' [i64]\n",
       "[\n",
       "\t20220721\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t…\n",
       "\t20220711\n",
       "\t20220711\n",
       "\t20220711\n",
       "\t20220711\n",
       "\t20220707\n",
       "]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_series()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "b31901a5-8bca-4220-93bf-6a9790089cf9",
   "metadata": {},
   "outputs": [],
   "source": [
    "s = df.to_series()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "bd7cc2fd-8893-4ffa-bc8c-fa3329cb13b1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'发生日期'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "ac8db260-2f8f-4ade-91ce-0ce3fe0ef5ee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Int64"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.dtype"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "1f7f8d2f-6a0f-4673-a2d7-cafd8304f57a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(17,)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "ffddeb3c-027a-4687-ab66-f5a3d1f7de9d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "17"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.len()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "07415504-ba8a-4615-8be4-eb6eed2d47a7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (5,)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th></tr><tr><td>i64</td></tr></thead><tbody><tr><td>20220721</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (5,)\n",
       "Series: '发生日期' [i64]\n",
       "[\n",
       "\t20220721\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t20220718\n",
       "]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s[:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "1807ba3b-4ce0-4baf-b596-ece6a878d2f0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (10,)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th></tr><tr><td>str</td></tr></thead><tbody><tr><td>&quot;600648&quot;</td></tr><tr><td>&quot;=&quot;002462&quot;&quot;</td></tr><tr><td>&quot;600269&quot;</td></tr><tr><td>&quot;=&quot;000900&quot;&quot;</td></tr><tr><td>&quot;601077&quot;</td></tr><tr><td>&quot;204007&quot;</td></tr><tr><td>&quot;600408&quot;</td></tr><tr><td>&quot;600015&quot;</td></tr><tr><td>&quot;601992&quot;</td></tr><tr><td>&quot;600894&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (10,)\n",
       "Series: '证券代码' [str]\n",
       "[\n",
       "\t\"600648\"\n",
       "\t\"=\"002462\"\"\n",
       "\t\"600269\"\n",
       "\t\"=\"000900\"\"\n",
       "\t\"601077\"\n",
       "\t\"204007\"\n",
       "\t\"600408\"\n",
       "\t\"600015\"\n",
       "\t\"601992\"\n",
       "\t\"600894\"\n",
       "]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_series(1).unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "2a5bfd64-05f0-4ea7-a7aa-76f04c1fc3b7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17, 2)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>成交时间</th><th>count</th></tr><tr><td>str</td><td>u32</td></tr></thead><tbody><tr><td>&quot;09:38:10&quot;</td><td>1</td></tr><tr><td>&quot;09:44:31&quot;</td><td>1</td></tr><tr><td>&quot;09:33:37&quot;</td><td>1</td></tr><tr><td>&quot;19:03:27&quot;</td><td>1</td></tr><tr><td>&quot;09:39:27&quot;</td><td>1</td></tr><tr><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;09:38:16&quot;</td><td>1</td></tr><tr><td>&quot;09:38:30&quot;</td><td>1</td></tr><tr><td>&quot;09:39:06&quot;</td><td>1</td></tr><tr><td>&quot;09:43:38&quot;</td><td>1</td></tr><tr><td>&quot;09:39:28&quot;</td><td>1</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17, 2)\n",
       "┌──────────┬───────┐\n",
       "│ 成交时间 ┆ count │\n",
       "│ ---      ┆ ---   │\n",
       "│ str      ┆ u32   │\n",
       "╞══════════╪═══════╡\n",
       "│ 09:38:10 ┆ 1     │\n",
       "│ 09:44:31 ┆ 1     │\n",
       "│ 09:33:37 ┆ 1     │\n",
       "│ 19:03:27 ┆ 1     │\n",
       "│ 09:39:27 ┆ 1     │\n",
       "│ …        ┆ …     │\n",
       "│ 09:38:16 ┆ 1     │\n",
       "│ 09:38:30 ┆ 1     │\n",
       "│ 09:39:06 ┆ 1     │\n",
       "│ 09:43:38 ┆ 1     │\n",
       "│ 09:39:28 ┆ 1     │\n",
       "└──────────┴───────┘"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_series(5).value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "ae278273-32e8-40de-8c4b-445a14eddb33",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (9, 2)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>statistic</th><th>value</th></tr><tr><td>str</td><td>f64</td></tr></thead><tbody><tr><td>&quot;count&quot;</td><td>17.0</td></tr><tr><td>&quot;null_count&quot;</td><td>0.0</td></tr><tr><td>&quot;mean&quot;</td><td>815.642353</td></tr><tr><td>&quot;std&quot;</td><td>230047.143813</td></tr><tr><td>&quot;min&quot;</td><td>-152125.86</td></tr><tr><td>&quot;25%&quot;</td><td>-140526.48</td></tr><tr><td>&quot;50%&quot;</td><td>-139342.29</td></tr><tr><td>&quot;75%&quot;</td><td>136953.55</td></tr><tr><td>&quot;max&quot;</td><td>758357.61</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (9, 2)\n",
       "┌────────────┬───────────────┐\n",
       "│ statistic  ┆ value         │\n",
       "│ ---        ┆ ---           │\n",
       "│ str        ┆ f64           │\n",
       "╞════════════╪═══════════════╡\n",
       "│ count      ┆ 17.0          │\n",
       "│ null_count ┆ 0.0           │\n",
       "│ mean       ┆ 815.642353    │\n",
       "│ std        ┆ 230047.143813 │\n",
       "│ min        ┆ -152125.86    │\n",
       "│ 25%        ┆ -140526.48    │\n",
       "│ 50%        ┆ -139342.29    │\n",
       "│ 75%        ┆ 136953.55     │\n",
       "│ max        ┆ 758357.61     │\n",
       "└────────────┴───────────────┘"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:,\"发生金额\"].describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "0818bbcd-0f02-464c-9514-03cb590c26ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<bound method Series.to_list of shape: (17,)\n",
       "Series: '发生金额' [f64]\n",
       "[\n",
       "\t4884.0\n",
       "\t58018.63\n",
       "\t137184.67\n",
       "\t-149955.5\n",
       "\t-150044.49\n",
       "\t…\n",
       "\t-58002.9\n",
       "\t-139883.8\n",
       "\t-139979.8\n",
       "\t-139818.75\n",
       "\t758357.61\n",
       "]>"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:,\"发生金额\"].to_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "6ecabc1f-ced7-44eb-aeed-de7c0272b0ad",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Rows: 17\n",
      "Columns: 16\n",
      "$ 发生日期 <i64> 20220721, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718\n",
      "$ 证券代码 <str> '600269', '204007', '=\"002462\"', '600408', '600648', '600269', '600015', '601992', '600894', '601077'\n",
      "$ 证券名称 <str> '赣粤高速', 'GC007', '嘉事堂', '安泰集团', '外高桥', '赣粤高速', '华夏银行', '金隅集团', '广日股份', '渝农商行'\n",
      "$ 买卖标志 <str> '卖出', '卖出', '卖出', '买入', '买入', '买入', '买入', '卖出', '卖出', '卖出'\n",
      "$ 业务名称 <str> '股息入账', '拆出质押购回', '证券卖出', '证券买入', '证券买入', '证券买入', '证券买入', '证券卖出', '证券卖出', '证券卖出'\n",
      "$ 成交时间 <str> '16:00:00', '19:03:27', '09:38:10', '09:44:52', '09:44:31', '09:43:38', '09:42:51', '09:39:28', '09:39:06', '09:38:30'\n",
      "$ 成交数量 <str> '=\"0.00\"', '-580.00', '-10400.00', '47000.00', '11900.00', '40700.00', '30000.00', '-54000.00', '-21400.00', '-38300.00'\n",
      "$ 成交价格 <f64> 3.6, 1.675, 13.2062, 3.19, 12.6066, 3.69, 5.07, 2.5683, 6.5419, 3.58\n",
      "$ 成交金额 <f64> 4884.0, 58000.0, 137344.0, 149930.0, 150019.0, 150183.0, 152100.0, 138686.0, 139996.0, 137114.0\n",
      "$ 发生金额 <f64> 4884.0, 58018.63, 137184.67, -149955.5, -150044.49, -150208.53, -152125.86, 138523.74, 139832.12, 136953.55\n",
      "$ 手续费  <str> '=\"0.00\"', '=\"0.00\"', '21.98', '23.99', '24.00', '24.03', '24.34', '22.19', '22.40', '21.94'\n",
      "$ 印花税  <str> '=\"0.00\"', '=\"0.00\"', '137.35', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '138.69', '140.02', '137.13'\n",
      "$ 过户费  <str> '=\"0.00\"', '=\"0.00\"', '1.38', '1.51', '1.49', '1.50', '1.52', '1.38', '1.46', '1.38'\n",
      "$ 其他费  <str> '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"'\n",
      "$ 备注   <str> '股息入账:赣粤高速600269; 权益股数:40700;', '融券购回:18.63实际占款天数：7-888880', '证券卖出', '证券买入', '证券买入', '证券买入', '证券买入', '证券卖出', '证券卖出', '证券卖出'\n",
      "$ 币种   <str> '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币'\n",
      "\n"
     ]
    }
   ],
   "source": [
    "df.glimpse()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "3e9fcc5a-e14b-467a-8920-0f57e0955270",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;20220721&quot;</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;卖出&quot;</td><td>&quot;股息入账&quot;</td><td>&quot;16:00:00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;3.6000&quot;</td><td>&quot;4884.00&quot;</td><td>&quot;4884.00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;股息入账:赣粤高速600269; 权益股数:40700;&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&quot;20220718&quot;</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:03:27&quot;</td><td>&quot;-580.00&quot;</td><td>&quot;1.6750&quot;</td><td>&quot;58000.00&quot;</td><td>&quot;58018.63&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:18.63实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&quot;20220718&quot;</td><td>&quot;=&quot;002462&quot;&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;09:38:10&quot;</td><td>&quot;-10400.00&quot;</td><td>&quot;13.2062&quot;</td><td>&quot;137344.00&quot;</td><td>&quot;137184.67&quot;</td><td>&quot;21.98&quot;</td><td>&quot;137.35&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&quot;20220718&quot;</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:52&quot;</td><td>&quot;47000.00&quot;</td><td>&quot;3.1900&quot;</td><td>&quot;149930.00&quot;</td><td>&quot;-149955.50&quot;</td><td>&quot;23.99&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.51&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&quot;20220718&quot;</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:31&quot;</td><td>&quot;11900.00&quot;</td><td>&quot;12.6066&quot;</td><td>&quot;150019.00&quot;</td><td>&quot;-150044.49&quot;</td><td>&quot;24.00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.49&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;20220711&quot;</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;质押回购拆出&quot;</td><td>&quot;09:39:27&quot;</td><td>&quot;580.00&quot;</td><td>&quot;1.6750&quot;</td><td>&quot;58000.00&quot;</td><td>&quot;-58002.90&quot;</td><td>&quot;2.90&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券回购购回日:20220718预计利息:18.63参考占款…</td><td>&quot;人民币&quot;</td></tr><tr><td>&quot;20220711&quot;</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:37:25&quot;</td><td>&quot;54000.00&quot;</td><td>&quot;2.5900&quot;</td><td>&quot;139860.00&quot;</td><td>&quot;-139883.80&quot;</td><td>&quot;22.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.42&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&quot;20220711&quot;</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:36:30&quot;</td><td>&quot;21400.00&quot;</td><td>&quot;6.5400&quot;</td><td>&quot;139956.00&quot;</td><td>&quot;-139979.80&quot;</td><td>&quot;22.39&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.41&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&quot;20220711&quot;</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:34:24&quot;</td><td>&quot;38300.00&quot;</td><td>&quot;3.6500&quot;</td><td>&quot;139795.00&quot;</td><td>&quot;-139818.75&quot;</td><td>&quot;22.37&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&quot;20220707&quot;</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:17:51&quot;</td><td>&quot;-7580.00&quot;</td><td>&quot;2.4600&quot;</td><td>&quot;758000.00&quot;</td><td>&quot;758357.61&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:357.61实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ str    ┆ str    ┆ str    ┆ str    │\n",
       "│ str     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022072 ┆ 600269  ┆ 赣粤高  ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 股息入 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 速      ┆        ┆   ┆ \"      ┆ \"      ┆ 账:赣  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 粤高速 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 600269 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ ; 权益 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 股数:4 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 0700;  ┆        │\n",
       "│ 2022071 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券购 ┆ 人民币 │\n",
       "│ 8       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 回:18. ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 63实际 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 占款天 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 数：7- ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 888880 ┆        │\n",
       "│ 2022071 ┆ =\"00246 ┆ 嘉事堂  ┆ 卖出   ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 证券卖 ┆ 人民币 │\n",
       "│ 8       ┆ 2\"      ┆         ┆        ┆   ┆        ┆ \"      ┆ 出     ┆        │\n",
       "│ 2022071 ┆ 600408  ┆ 安泰集  ┆ 买入   ┆ … ┆ 1.51   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 8       ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 600648  ┆ 外高桥  ┆ 买入   ┆ … ┆ 1.49   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 8       ┆         ┆         ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 2022071 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券回 ┆ 人民币 │\n",
       "│ 1       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 购购回 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 日:202 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 20718  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 预计利 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 息:18. ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 63参考 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 占款…  ┆        │\n",
       "│ 2022071 ┆ 601992  ┆ 金隅集  ┆ 买入   ┆ … ┆ 1.42   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 600894  ┆ 广日股  ┆ 买入   ┆ … ┆ 1.41   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 份      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 601077  ┆ 渝农商  ┆ 买入   ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 行      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022070 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券购 ┆ 人民币 │\n",
       "│ 7       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 回:357 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ .61实  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 际占款 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 天数： ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 7-8888 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 80     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pl.read_csv(\"stock_trades/202207-湘财.xls\",encoding=\"gb18030\",separator=\"\\t\",infer_schema=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "e21a5bd4-3653-4d25-8372-55fdc4719b4a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220721</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;卖出&quot;</td><td>&quot;股息入账&quot;</td><td>&quot;16:00:00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>3.6</td><td>4884.0</td><td>4884.0</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;股息入账:赣粤高速600269; 权益股数:40700;&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:03:27&quot;</td><td>&quot;-580.00&quot;</td><td>1.675</td><td>58000.0</td><td>58018.63</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:18.63实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;=&quot;002462&quot;&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;09:38:10&quot;</td><td>&quot;-10400.00&quot;</td><td>13.2062</td><td>137344.0</td><td>137184.67</td><td>&quot;21.98&quot;</td><td>&quot;137.35&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:52&quot;</td><td>&quot;47000.00&quot;</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>&quot;23.99&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.51&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:31&quot;</td><td>&quot;11900.00&quot;</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>&quot;24.00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.49&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>20220711</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;质押回购拆出&quot;</td><td>&quot;09:39:27&quot;</td><td>&quot;580.00&quot;</td><td>1.675</td><td>58000.0</td><td>-58002.9</td><td>&quot;2.90&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券回购购回日:20220718预计利息:18.63参考占款…</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:37:25&quot;</td><td>&quot;54000.00&quot;</td><td>2.59</td><td>139860.0</td><td>-139883.8</td><td>&quot;22.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.42&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:36:30&quot;</td><td>&quot;21400.00&quot;</td><td>6.54</td><td>139956.0</td><td>-139979.8</td><td>&quot;22.39&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.41&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:34:24&quot;</td><td>&quot;38300.00&quot;</td><td>3.65</td><td>139795.0</td><td>-139818.75</td><td>&quot;22.37&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220707</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:17:51&quot;</td><td>&quot;-7580.00&quot;</td><td>2.46</td><td>758000.0</td><td>758357.61</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:357.61实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ str    ┆ str    ┆ str    ┆ str    │\n",
       "│ i64     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022072 ┆ 600269  ┆ 赣粤高  ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 股息入 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 速      ┆        ┆   ┆ \"      ┆ \"      ┆ 账:赣  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 粤高速 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 600269 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ ; 权益 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 股数:4 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 0700;  ┆        │\n",
       "│ 2022071 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券购 ┆ 人民币 │\n",
       "│ 8       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 回:18. ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 63实际 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 占款天 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 数：7- ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 888880 ┆        │\n",
       "│ 2022071 ┆ =\"00246 ┆ 嘉事堂  ┆ 卖出   ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 证券卖 ┆ 人民币 │\n",
       "│ 8       ┆ 2\"      ┆         ┆        ┆   ┆        ┆ \"      ┆ 出     ┆        │\n",
       "│ 2022071 ┆ 600408  ┆ 安泰集  ┆ 买入   ┆ … ┆ 1.51   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 8       ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 600648  ┆ 外高桥  ┆ 买入   ┆ … ┆ 1.49   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 8       ┆         ┆         ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 2022071 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券回 ┆ 人民币 │\n",
       "│ 1       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 购购回 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 日:202 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 20718  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 预计利 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 息:18. ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 63参考 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 占款…  ┆        │\n",
       "│ 2022071 ┆ 601992  ┆ 金隅集  ┆ 买入   ┆ … ┆ 1.42   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 600894  ┆ 广日股  ┆ 买入   ┆ … ┆ 1.41   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 份      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022071 ┆ 601077  ┆ 渝农商  ┆ 买入   ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ 1       ┆         ┆ 行      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022070 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券购 ┆ 人民币 │\n",
       "│ 7       ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 回:357 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ .61实  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 际占款 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 天数： ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 7-8888 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 80     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "9fe30e30-437a-4218-895d-046456f826f9",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "SchemaError",
     "evalue": "invalid series dtype: expected `String`, got `i64` for series with name `发生日期`",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mSchemaError\u001b[39m                               Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[28]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mdf\u001b[49m\u001b[43m.\u001b[49m\u001b[43mwith_columns\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m      2\u001b[39m \u001b[43m    \u001b[49m\u001b[43mpl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcol\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m发生日期\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstr\u001b[49m\u001b[43m.\u001b[49m\u001b[43mto_date\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m%\u001b[39;49m\u001b[33;43mY\u001b[39;49m\u001b[33;43m%\u001b[39;49m\u001b[33;43mm\u001b[39;49m\u001b[38;5;132;43;01m%d\u001b[39;49;00m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m      3\u001b[39m \u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~\\anaconda3\\envs\\week08\\Lib\\site-packages\\polars\\dataframe\\frame.py:9830\u001b[39m, in \u001b[36mDataFrame.with_columns\u001b[39m\u001b[34m(self, *exprs, **named_exprs)\u001b[39m\n\u001b[32m   9684\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mwith_columns\u001b[39m(\n\u001b[32m   9685\u001b[39m     \u001b[38;5;28mself\u001b[39m,\n\u001b[32m   9686\u001b[39m     *exprs: IntoExpr | Iterable[IntoExpr],\n\u001b[32m   9687\u001b[39m     **named_exprs: IntoExpr,\n\u001b[32m   9688\u001b[39m ) -> DataFrame:\n\u001b[32m   9689\u001b[39m \u001b[38;5;250m    \u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m   9690\u001b[39m \u001b[33;03m    Add columns to this DataFrame.\u001b[39;00m\n\u001b[32m   9691\u001b[39m \n\u001b[32m   (...)\u001b[39m\u001b[32m   9828\u001b[39m \u001b[33;03m    └─────┴──────┴─────────────┘\u001b[39;00m\n\u001b[32m   9829\u001b[39m \u001b[33;03m    \"\"\"\u001b[39;00m\n\u001b[32m-> \u001b[39m\u001b[32m9830\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mlazy\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mwith_columns\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43mexprs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mnamed_exprs\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcollect\u001b[49m\u001b[43m(\u001b[49m\u001b[43m_eager\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~\\anaconda3\\envs\\week08\\Lib\\site-packages\\polars\\_utils\\deprecation.py:93\u001b[39m, in \u001b[36mdeprecate_streaming_parameter.<locals>.decorate.<locals>.wrapper\u001b[39m\u001b[34m(*args, **kwargs)\u001b[39m\n\u001b[32m     89\u001b[39m         kwargs[\u001b[33m\"\u001b[39m\u001b[33mengine\u001b[39m\u001b[33m\"\u001b[39m] = \u001b[33m\"\u001b[39m\u001b[33min-memory\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m     91\u001b[39m     \u001b[38;5;28;01mdel\u001b[39;00m kwargs[\u001b[33m\"\u001b[39m\u001b[33mstreaming\u001b[39m\u001b[33m\"\u001b[39m]\n\u001b[32m---> \u001b[39m\u001b[32m93\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunction\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~\\anaconda3\\envs\\week08\\Lib\\site-packages\\polars\\lazyframe\\frame.py:2224\u001b[39m, in \u001b[36mLazyFrame.collect\u001b[39m\u001b[34m(self, type_coercion, _type_check, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, cluster_with_columns, collapse_joins, no_optimization, engine, background, _check_order, _eager, **_kwargs)\u001b[39m\n\u001b[32m   2222\u001b[39m \u001b[38;5;66;03m# Only for testing purposes\u001b[39;00m\n\u001b[32m   2223\u001b[39m callback = _kwargs.get(\u001b[33m\"\u001b[39m\u001b[33mpost_opt_callback\u001b[39m\u001b[33m\"\u001b[39m, callback)\n\u001b[32m-> \u001b[39m\u001b[32m2224\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m wrap_df(\u001b[43mldf\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcollect\u001b[49m\u001b[43m(\u001b[49m\u001b[43mengine\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcallback\u001b[49m\u001b[43m)\u001b[49m)\n",
      "\u001b[31mSchemaError\u001b[39m: invalid series dtype: expected `String`, got `i64` for series with name `发生日期`"
     ]
    }
   ],
   "source": [
    "df.with_columns(\n",
    "    pl.col(\"发生日期\").str.to_date(\"%Y%m%d\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "3f160fc2-245e-4ae9-b6da-748d6758fe7b",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df.with_columns(\n",
    "    pl.col(\"发生日期\").cast(pl.Utf8).str.to_date(\"%Y%m%d\")\n",
    ")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "5f230283-69ee-49be-b3dd-ab0f7e702903",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>2022-07-21</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;卖出&quot;</td><td>&quot;股息入账&quot;</td><td>&quot;16:00:00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>3.6</td><td>4884.0</td><td>4884.0</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;股息入账:赣粤高速600269; 权益股数:40700;&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:03:27&quot;</td><td>&quot;-580.00&quot;</td><td>1.675</td><td>58000.0</td><td>58018.63</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:18.63实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;=&quot;002462&quot;&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;09:38:10&quot;</td><td>&quot;-10400.00&quot;</td><td>13.2062</td><td>137344.0</td><td>137184.67</td><td>&quot;21.98&quot;</td><td>&quot;137.35&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:52&quot;</td><td>&quot;47000.00&quot;</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>&quot;23.99&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.51&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:31&quot;</td><td>&quot;11900.00&quot;</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>&quot;24.00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.49&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>2022-07-11</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;质押回购拆出&quot;</td><td>&quot;09:39:27&quot;</td><td>&quot;580.00&quot;</td><td>1.675</td><td>58000.0</td><td>-58002.9</td><td>&quot;2.90&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券回购购回日:20220718预计利息:18.63参考占款…</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-11</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:37:25&quot;</td><td>&quot;54000.00&quot;</td><td>2.59</td><td>139860.0</td><td>-139883.8</td><td>&quot;22.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.42&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-11</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:36:30&quot;</td><td>&quot;21400.00&quot;</td><td>6.54</td><td>139956.0</td><td>-139979.8</td><td>&quot;22.39&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.41&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-11</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:34:24&quot;</td><td>&quot;38300.00&quot;</td><td>3.65</td><td>139795.0</td><td>-139818.75</td><td>&quot;22.37&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-07</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:17:51&quot;</td><td>&quot;-7580.00&quot;</td><td>2.46</td><td>758000.0</td><td>758357.61</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:357.61实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ str    ┆ str    ┆ str    ┆ str    │\n",
       "│ date    ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022-07 ┆ 600269  ┆ 赣粤高  ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 股息入 ┆ 人民币 │\n",
       "│ -21     ┆         ┆ 速      ┆        ┆   ┆ \"      ┆ \"      ┆ 账:赣  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 粤高速 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 600269 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ ; 权益 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 股数:4 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 0700;  ┆        │\n",
       "│ 2022-07 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券购 ┆ 人民币 │\n",
       "│ -18     ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 回:18. ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 63实际 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 占款天 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 数：7- ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 888880 ┆        │\n",
       "│ 2022-07 ┆ =\"00246 ┆ 嘉事堂  ┆ 卖出   ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 证券卖 ┆ 人民币 │\n",
       "│ -18     ┆ 2\"      ┆         ┆        ┆   ┆        ┆ \"      ┆ 出     ┆        │\n",
       "│ 2022-07 ┆ 600408  ┆ 安泰集  ┆ 买入   ┆ … ┆ 1.51   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ -18     ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 600648  ┆ 外高桥  ┆ 买入   ┆ … ┆ 1.49   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ -18     ┆         ┆         ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 2022-07 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券回 ┆ 人民币 │\n",
       "│ -11     ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 购购回 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 日:202 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 20718  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 预计利 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 息:18. ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 63参考 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 占款…  ┆        │\n",
       "│ 2022-07 ┆ 601992  ┆ 金隅集  ┆ 买入   ┆ … ┆ 1.42   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ -11     ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 600894  ┆ 广日股  ┆ 买入   ┆ … ┆ 1.41   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ -11     ┆         ┆ 份      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 601077  ┆ 渝农商  ┆ 买入   ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ -11     ┆         ┆ 行      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 204007  ┆ GC007   ┆ 卖出   ┆ … ┆ =\"0.00 ┆ =\"0.00 ┆ 融券购 ┆ 人民币 │\n",
       "│ -07     ┆         ┆         ┆        ┆   ┆ \"      ┆ \"      ┆ 回:357 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ .61实  ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 际占款 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 天数： ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 7-8888 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 80     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "95b052a9-e83e-4242-9db2-a1ffb35f97aa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Schema([('发生日期', Date),\n",
       "        ('证券代码', String),\n",
       "        ('证券名称', String),\n",
       "        ('买卖标志', String),\n",
       "        ('业务名称', String),\n",
       "        ('成交时间', String),\n",
       "        ('成交数量', String),\n",
       "        ('成交价格', Float64),\n",
       "        ('成交金额', Float64),\n",
       "        ('发生金额', Float64),\n",
       "        ('手续费', String),\n",
       "        ('印花税', String),\n",
       "        ('过户费', String),\n",
       "        ('其他费', String),\n",
       "        ('备注', String),\n",
       "        ('币种', String)])"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.schema"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "b78d5a26-863f-4fc9-92be-4b39f4691360",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['600269',\n",
       " '=\"000900\"',\n",
       " '204007',\n",
       " '600648',\n",
       " '600015',\n",
       " '601992',\n",
       " '=\"002462\"',\n",
       " '600894',\n",
       " '600408',\n",
       " '601077']"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:,\"证券代码\"].unique().to_list()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "df3a6e13-900b-4ac0-8bfd-25ee40301293",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "ename": "SchemaError",
     "evalue": "invalid series dtype: expected `String`, got `time` for series with name `成交时间`",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mSchemaError\u001b[39m                               Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[48]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m df = \u001b[43mdf\u001b[49m\u001b[43m.\u001b[49m\u001b[43mwith_columns\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m      2\u001b[39m \u001b[43m    \u001b[49m\u001b[43mpl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcol\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m发生日期\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcast\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mUtf8\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstr\u001b[49m\u001b[43m.\u001b[49m\u001b[43mto_date\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m%\u001b[39;49m\u001b[33;43mY-\u001b[39;49m\u001b[33;43m%\u001b[39;49m\u001b[33;43mm-\u001b[39;49m\u001b[38;5;132;43;01m%d\u001b[39;49;00m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m  \u001b[49m\u001b[38;5;66;43;03m# 修改了日期格式\u001b[39;49;00m\n\u001b[32m      3\u001b[39m \u001b[43m    \u001b[49m\u001b[43mpl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcol\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m证券代码\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstr\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstrip_prefix\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m=\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstr\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstrip_chars\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m      4\u001b[39m \u001b[43m    \u001b[49m\u001b[43mpl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcol\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m成交时间\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstr\u001b[49m\u001b[43m.\u001b[49m\u001b[43mto_time\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m      5\u001b[39m \u001b[43m    \u001b[49m\u001b[43mpl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcol\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m成交数量\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcast\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mFloat64\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m      6\u001b[39m \u001b[43m)\u001b[49m\n\u001b[32m      7\u001b[39m df = df.filter(pl.col(\u001b[33m\"\u001b[39m\u001b[33m业务名称\u001b[39m\u001b[33m\"\u001b[39m).is_in([\u001b[33m\"\u001b[39m\u001b[33m证券买入\u001b[39m\u001b[33m\"\u001b[39m,\u001b[33m\"\u001b[39m\u001b[33m证券卖出\u001b[39m\u001b[33m\"\u001b[39m]),  \n\u001b[32m      8\u001b[39m )\n\u001b[32m      9\u001b[39m df\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~\\anaconda3\\envs\\week08\\Lib\\site-packages\\polars\\dataframe\\frame.py:9830\u001b[39m, in \u001b[36mDataFrame.with_columns\u001b[39m\u001b[34m(self, *exprs, **named_exprs)\u001b[39m\n\u001b[32m   9684\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mwith_columns\u001b[39m(\n\u001b[32m   9685\u001b[39m     \u001b[38;5;28mself\u001b[39m,\n\u001b[32m   9686\u001b[39m     *exprs: IntoExpr | Iterable[IntoExpr],\n\u001b[32m   9687\u001b[39m     **named_exprs: IntoExpr,\n\u001b[32m   9688\u001b[39m ) -> DataFrame:\n\u001b[32m   9689\u001b[39m \u001b[38;5;250m    \u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m   9690\u001b[39m \u001b[33;03m    Add columns to this DataFrame.\u001b[39;00m\n\u001b[32m   9691\u001b[39m \n\u001b[32m   (...)\u001b[39m\u001b[32m   9828\u001b[39m \u001b[33;03m    └─────┴──────┴─────────────┘\u001b[39;00m\n\u001b[32m   9829\u001b[39m \u001b[33;03m    \"\"\"\u001b[39;00m\n\u001b[32m-> \u001b[39m\u001b[32m9830\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mlazy\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mwith_columns\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43mexprs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mnamed_exprs\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcollect\u001b[49m\u001b[43m(\u001b[49m\u001b[43m_eager\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~\\anaconda3\\envs\\week08\\Lib\\site-packages\\polars\\_utils\\deprecation.py:93\u001b[39m, in \u001b[36mdeprecate_streaming_parameter.<locals>.decorate.<locals>.wrapper\u001b[39m\u001b[34m(*args, **kwargs)\u001b[39m\n\u001b[32m     89\u001b[39m         kwargs[\u001b[33m\"\u001b[39m\u001b[33mengine\u001b[39m\u001b[33m\"\u001b[39m] = \u001b[33m\"\u001b[39m\u001b[33min-memory\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m     91\u001b[39m     \u001b[38;5;28;01mdel\u001b[39;00m kwargs[\u001b[33m\"\u001b[39m\u001b[33mstreaming\u001b[39m\u001b[33m\"\u001b[39m]\n\u001b[32m---> \u001b[39m\u001b[32m93\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunction\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~\\anaconda3\\envs\\week08\\Lib\\site-packages\\polars\\lazyframe\\frame.py:2224\u001b[39m, in \u001b[36mLazyFrame.collect\u001b[39m\u001b[34m(self, type_coercion, _type_check, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, cluster_with_columns, collapse_joins, no_optimization, engine, background, _check_order, _eager, **_kwargs)\u001b[39m\n\u001b[32m   2222\u001b[39m \u001b[38;5;66;03m# Only for testing purposes\u001b[39;00m\n\u001b[32m   2223\u001b[39m callback = _kwargs.get(\u001b[33m\"\u001b[39m\u001b[33mpost_opt_callback\u001b[39m\u001b[33m\"\u001b[39m, callback)\n\u001b[32m-> \u001b[39m\u001b[32m2224\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m wrap_df(\u001b[43mldf\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcollect\u001b[49m\u001b[43m(\u001b[49m\u001b[43mengine\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcallback\u001b[49m\u001b[43m)\u001b[49m)\n",
      "\u001b[31mSchemaError\u001b[39m: invalid series dtype: expected `String`, got `time` for series with name `成交时间`"
     ]
    }
   ],
   "source": [
    "df = df.with_columns(\n",
    "    pl.col(\"发生日期\").cast(pl.Utf8).str.to_date(\"%Y-%m-%d\"),  # 修改了日期格式\n",
    "    pl.col(\"证券代码\").str.strip_prefix(\"=\").str.strip_chars('\"'),\n",
    "    pl.col(\"成交时间\").str.to_time(),\n",
    "    pl.col(\"成交数量\").cast(pl.Float64),\n",
    ")\n",
    "df = df.filter(pl.col(\"业务名称\").is_in([\"证券买入\",\"证券卖出\"]),  \n",
    ")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "eaffe601-d937-4a29-9f75-64060332e5d4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (13, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>time</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>2022-07-18</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>09:38:10</td><td>-10400.0</td><td>13.2062</td><td>137344.0</td><td>137184.67</td><td>&quot;21.98&quot;</td><td>&quot;137.35&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:44:52</td><td>47000.0</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>&quot;23.99&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.51&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:44:31</td><td>11900.0</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>&quot;24.00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.49&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:43:38</td><td>40700.0</td><td>3.69</td><td>150183.0</td><td>-150208.53</td><td>&quot;24.03&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.50&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600015&quot;</td><td>&quot;华夏银行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:42:51</td><td>30000.0</td><td>5.07</td><td>152100.0</td><td>-152125.86</td><td>&quot;24.34&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.52&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>2022-07-11</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:38:16</td><td>10400.0</td><td>13.51</td><td>140504.0</td><td>-140526.48</td><td>&quot;22.48&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.41&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-11</td><td>&quot;000900&quot;</td><td>&quot;现代投资&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:33:37</td><td>34400.0</td><td>4.05</td><td>139320.0</td><td>-139342.29</td><td>&quot;22.29&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.39&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-11</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:37:25</td><td>54000.0</td><td>2.59</td><td>139860.0</td><td>-139883.8</td><td>&quot;22.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.42&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-11</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:36:30</td><td>21400.0</td><td>6.54</td><td>139956.0</td><td>-139979.8</td><td>&quot;22.39&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.41&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-11</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:34:24</td><td>38300.0</td><td>3.65</td><td>139795.0</td><td>-139818.75</td><td>&quot;22.37&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (13, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ str    ┆ str    ┆ str    ┆ str    │\n",
       "│ date    ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022-07 ┆ 002462  ┆ 嘉事堂  ┆ 卖出   ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 证券卖 ┆ 人民币 │\n",
       "│ -18     ┆         ┆         ┆        ┆   ┆        ┆ \"      ┆ 出     ┆        │\n",
       "│ 2022-07 ┆ 600408  ┆ 安泰集  ┆ 买入   ┆ … ┆ 1.51   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ -18     ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 600648  ┆ 外高桥  ┆ 买入   ┆ … ┆ 1.49   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ -18     ┆         ┆         ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 600269  ┆ 赣粤高  ┆ 买入   ┆ … ┆ 1.50   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ -18     ┆         ┆ 速      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 600015  ┆ 华夏银  ┆ 买入   ┆ … ┆ 1.52   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ -18     ┆         ┆ 行      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 2022-07 ┆ 002462  ┆ 嘉事堂  ┆ 买入   ┆ … ┆ 1.41   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ -11     ┆         ┆         ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 000900  ┆ 现代投  ┆ 买入   ┆ … ┆ 1.39   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ -11     ┆         ┆ 资      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 601992  ┆ 金隅集  ┆ 买入   ┆ … ┆ 1.42   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ -11     ┆         ┆ 团      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 600894  ┆ 广日股  ┆ 买入   ┆ … ┆ 1.41   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ -11     ┆         ┆ 份      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 601077  ┆ 渝农商  ┆ 买入   ┆ … ┆ 1.38   ┆ =\"0.00 ┆ 证券买 ┆ 人民币 │\n",
       "│ -11     ┆         ┆ 行      ┆        ┆   ┆        ┆ \"      ┆ 入     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = df.with_columns(\n",
    "    pl.col(\"发生日期\").cast(pl.Utf8).str.to_date(\"%Y-%m-%d\"),\n",
    "    pl.col(\"证券代码\").str.strip_prefix(\"=\").str.strip_chars('\"'),\n",
    "    pl.col(\"成交时间\").cast(pl.Utf8).str.to_time(),  # 先转为字符串，再转为时间\n",
    "    pl.col(\"成交数量\").cast(pl.Float64),\n",
    ")\n",
    "df = df.filter(pl.col(\"业务名称\").is_in([\"证券买入\",\"证券卖出\"]),  \n",
    ")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "d61ad6c0-11f2-4995-8324-b5e58ee08b9d",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "ename": "ComputeError",
     "evalue": "the name '发生日期' passed to `LazyFrame.with_columns` is duplicate\n\nIt's possible that multiple expressions are returning the same default column name. If this is the case, try renaming the columns with `.alias(\"new_name\")` to avoid duplicate column names.\n\nResolved plan until failure:\n\n\t---> FAILED HERE RESOLVING 'sink' <---\nDF [\"发生日期\", \"证券代码\", \"证券名称\", \"买卖标志\", ...]; PROJECT */16 COLUMNS",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mComputeError\u001b[39m                              Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[59]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m      1\u001b[39m df = pl.read_csv(\u001b[33m\"\u001b[39m\u001b[33mstock_trades/202207-湘财.xls\u001b[39m\u001b[33m\"\u001b[39m,encoding=\u001b[33m\"\u001b[39m\u001b[33mgb18030\u001b[39m\u001b[33m\"\u001b[39m,separator=\u001b[33m\"\u001b[39m\u001b[38;5;130;01m\\t\u001b[39;00m\u001b[33m\"\u001b[39m,infer_schema=\u001b[38;5;28;01mFalse\u001b[39;00m)\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m df = \u001b[43mdf\u001b[49m\u001b[43m.\u001b[49m\u001b[43mwith_columns\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m      3\u001b[39m \u001b[43m    \u001b[49m\u001b[43mpl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mselectors\u001b[49m\u001b[43m.\u001b[49m\u001b[43mall\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstr\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstrip_prefix\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m=\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstr\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstrip_chars\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m      4\u001b[39m \u001b[43m    \u001b[49m\u001b[43mpl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcol\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m发生日期\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcast\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mUtf8\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstr\u001b[49m\u001b[43m.\u001b[49m\u001b[43mto_date\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m%\u001b[39;49m\u001b[33;43mY-\u001b[39;49m\u001b[33;43m%\u001b[39;49m\u001b[33;43mm-\u001b[39;49m\u001b[38;5;132;43;01m%d\u001b[39;49;00m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m      5\u001b[39m \u001b[43m    \u001b[49m\u001b[43mpl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcol\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m成交时间\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcast\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mUtf8\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstr\u001b[49m\u001b[43m.\u001b[49m\u001b[43mto_time\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m  \u001b[49m\u001b[38;5;66;43;03m# 先转为字符串，再转为时间\u001b[39;49;00m\n\u001b[32m      6\u001b[39m \u001b[43m    \u001b[49m\u001b[43mpl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcol\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m成交数量\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m成交价格\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m成交金额\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m发生金额\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m手续费\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m印花税\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m过户费\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m其他费\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcast\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpl\u001b[49m\u001b[43m.\u001b[49m\u001b[43mFloat64\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m      7\u001b[39m \u001b[43m)\u001b[49m\n\u001b[32m      8\u001b[39m df = df.filter(\n\u001b[32m      9\u001b[39m     pl.col(\u001b[33m\"\u001b[39m\u001b[33m业务名称\u001b[39m\u001b[33m\"\u001b[39m).is_in([\u001b[33m\"\u001b[39m\u001b[33m证券买入\u001b[39m\u001b[33m\"\u001b[39m,\u001b[33m\"\u001b[39m\u001b[33m证券卖出\u001b[39m\u001b[33m\"\u001b[39m]),  \n\u001b[32m     10\u001b[39m )\n\u001b[32m     11\u001b[39m df\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~\\anaconda3\\envs\\week08\\Lib\\site-packages\\polars\\dataframe\\frame.py:9830\u001b[39m, in \u001b[36mDataFrame.with_columns\u001b[39m\u001b[34m(self, *exprs, **named_exprs)\u001b[39m\n\u001b[32m   9684\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mwith_columns\u001b[39m(\n\u001b[32m   9685\u001b[39m     \u001b[38;5;28mself\u001b[39m,\n\u001b[32m   9686\u001b[39m     *exprs: IntoExpr | Iterable[IntoExpr],\n\u001b[32m   9687\u001b[39m     **named_exprs: IntoExpr,\n\u001b[32m   9688\u001b[39m ) -> DataFrame:\n\u001b[32m   9689\u001b[39m \u001b[38;5;250m    \u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m   9690\u001b[39m \u001b[33;03m    Add columns to this DataFrame.\u001b[39;00m\n\u001b[32m   9691\u001b[39m \n\u001b[32m   (...)\u001b[39m\u001b[32m   9828\u001b[39m \u001b[33;03m    └─────┴──────┴─────────────┘\u001b[39;00m\n\u001b[32m   9829\u001b[39m \u001b[33;03m    \"\"\"\u001b[39;00m\n\u001b[32m-> \u001b[39m\u001b[32m9830\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mlazy\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mwith_columns\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43mexprs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mnamed_exprs\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcollect\u001b[49m\u001b[43m(\u001b[49m\u001b[43m_eager\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~\\anaconda3\\envs\\week08\\Lib\\site-packages\\polars\\_utils\\deprecation.py:93\u001b[39m, in \u001b[36mdeprecate_streaming_parameter.<locals>.decorate.<locals>.wrapper\u001b[39m\u001b[34m(*args, **kwargs)\u001b[39m\n\u001b[32m     89\u001b[39m         kwargs[\u001b[33m\"\u001b[39m\u001b[33mengine\u001b[39m\u001b[33m\"\u001b[39m] = \u001b[33m\"\u001b[39m\u001b[33min-memory\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m     91\u001b[39m     \u001b[38;5;28;01mdel\u001b[39;00m kwargs[\u001b[33m\"\u001b[39m\u001b[33mstreaming\u001b[39m\u001b[33m\"\u001b[39m]\n\u001b[32m---> \u001b[39m\u001b[32m93\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunction\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~\\anaconda3\\envs\\week08\\Lib\\site-packages\\polars\\lazyframe\\frame.py:2224\u001b[39m, in \u001b[36mLazyFrame.collect\u001b[39m\u001b[34m(self, type_coercion, _type_check, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, cluster_with_columns, collapse_joins, no_optimization, engine, background, _check_order, _eager, **_kwargs)\u001b[39m\n\u001b[32m   2222\u001b[39m \u001b[38;5;66;03m# Only for testing purposes\u001b[39;00m\n\u001b[32m   2223\u001b[39m callback = _kwargs.get(\u001b[33m\"\u001b[39m\u001b[33mpost_opt_callback\u001b[39m\u001b[33m\"\u001b[39m, callback)\n\u001b[32m-> \u001b[39m\u001b[32m2224\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m wrap_df(\u001b[43mldf\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcollect\u001b[49m\u001b[43m(\u001b[49m\u001b[43mengine\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcallback\u001b[49m\u001b[43m)\u001b[49m)\n",
      "\u001b[31mComputeError\u001b[39m: the name '发生日期' passed to `LazyFrame.with_columns` is duplicate\n\nIt's possible that multiple expressions are returning the same default column name. If this is the case, try renaming the columns with `.alias(\"new_name\")` to avoid duplicate column names.\n\nResolved plan until failure:\n\n\t---> FAILED HERE RESOLVING 'sink' <---\nDF [\"发生日期\", \"证券代码\", \"证券名称\", \"买卖标志\", ...]; PROJECT */16 COLUMNS"
     ]
    }
   ],
   "source": [
    "df = pl.read_csv(\"stock_trades/202207-湘财.xls\",encoding=\"gb18030\",separator=\"\\t\",infer_schema=False)\n",
    "df = df.with_columns(\n",
    "    pl.selectors.all().str.strip_prefix(\"=\").str.strip_chars('\"'),\n",
    "    pl.col(\"发生日期\").cast(pl.Utf8).str.to_date(\"%Y-%m-%d\"),\n",
    "    pl.col(\"成交时间\").cast(pl.Utf8).str.to_time(),  # 先转为字符串，再转为时间\n",
    "    pl.col(\"成交数量\",\"成交价格\",\"成交金额\",\"发生金额\",\"手续费\",\"印花税\",\"过户费\",\"其他费\").cast(pl.Float64),\n",
    ")\n",
    "df = df.filter(\n",
    "    pl.col(\"业务名称\").is_in([\"证券买入\",\"证券卖出\"]),  \n",
    ")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "a03ad7b6-12e8-4e8d-9a1b-faaa6966f91b",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pathlib import Path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "2e5130d4-fbb1-46e1-bddd-f284bfe2139d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[WindowsPath('stock_trades/202207-湘财.xls'),\n",
       " WindowsPath('stock_trades/202208-湘财.xls'),\n",
       " WindowsPath('stock_trades/202209-湘财.xls'),\n",
       " WindowsPath('stock_trades/202210-湘财.xls'),\n",
       " WindowsPath('stock_trades/202211-湘财.xls'),\n",
       " WindowsPath('stock_trades/202212-湘财.xls'),\n",
       " WindowsPath('stock_trades/202301-湘财.xls'),\n",
       " WindowsPath('stock_trades/202302-湘财.xls'),\n",
       " WindowsPath('stock_trades/202303-湘财.xls'),\n",
       " WindowsPath('stock_trades/202304-湘财.xls'),\n",
       " WindowsPath('stock_trades/202305-海通普通.xlsx'),\n",
       " WindowsPath('stock_trades/202305-湘财.xls'),\n",
       " WindowsPath('stock_trades/202306-海通普通.xlsx'),\n",
       " WindowsPath('stock_trades/202306-湘财.xls'),\n",
       " WindowsPath('stock_trades/202307-海通两融.xlsx'),\n",
       " WindowsPath('stock_trades/202307-海通普通.xlsx'),\n",
       " WindowsPath('stock_trades/202308-海通两融.xlsx'),\n",
       " WindowsPath('stock_trades/202309-海通两融.xlsx'),\n",
       " WindowsPath('stock_trades/202309-湘财.xls'),\n",
       " WindowsPath('stock_trades/202310-海通两融.xlsx')]"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(Path(\"stock_trades/\").iterdir())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "6bd3c374-f097-413f-b339-6ac636894be0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[f for f in Path(\"stock_trades/\").glob(\"*.湘财.xls\")]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "de3dae51-70a4-41f6-a224-5bfc76045552",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[f.stat().st.size for f in Path(\"stock_trades/\").glob(\"*.湘财.xls\")]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "5eb50f3b-35bc-42d6-b91f-1d959afd007b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[read_df_湘财(f) for f in Path(\"stock_trades/\").glob(\"*.湘财.xls\")]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "ea76d419-5b7b-4ac0-ba04-572aa4faf364",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "17"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "80f76b72-7792-4cc9-b697-80ba0b7ac823",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pathlib import Path\n",
    "import polars as pl\n",
    "\n",
    "def read_df_湘财(f: str | Path) -> pl.DataFrame:\n",
    "    df = pl.read_csv(\n",
    "        f,\n",
    "        encoding=\"gb18030\",\n",
    "        separator=\"\\t\",\n",
    "        infer_schema=False,\n",
    "    )\n",
    "    df = df.with_columns(\n",
    "        pl.selectors.all().str.strip_prefix(\"=\").str.strip_chars('\"'),\n",
    "        pl.col(\"发生日期\").cast(pl.Utf8).str.to_date(\"%Y-%m-%d\"),\n",
    "        pl.col(\"成交时间\").cast(pl.Utf8).str.to_time(),\n",
    "        pl.col([\"成交数量\", \"成交价格\", \"成交金额\", \"发生金额\", \"手续费\", \"印花税\", \"过户费\", \"其他费\"]).cast(pl.Float64),\n",
    "    )\n",
    "    df = df.filter(\n",
    "        pl.col(\"业务名称\").is_in([\"证券买入\", \"证券卖出\"]),  \n",
    "    )\n",
    "    return df\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "088a49b8-84c0-404f-a4ef-28c388da3bbd",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = [read_df_湘财(f) for f in Path(\"stock_trades/\").glob(\"*.湘财.xls\")]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "60934b2b-cd44-4c0f-9cea-79411a75c43b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "e4a636d4-85fa-4d80-9a26-f7757c0069b8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<generator object Path.iterdir at 0x0000016FA8117D30>"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Path(\"stock_trades/\").iterdir()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "072fb139-8102-414e-9efc-ec3bdd1584b1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[WindowsPath('stock_trades/202207-湘财.xls'),\n",
       " WindowsPath('stock_trades/202208-湘财.xls'),\n",
       " WindowsPath('stock_trades/202209-湘财.xls'),\n",
       " WindowsPath('stock_trades/202210-湘财.xls'),\n",
       " WindowsPath('stock_trades/202211-湘财.xls'),\n",
       " WindowsPath('stock_trades/202212-湘财.xls'),\n",
       " WindowsPath('stock_trades/202301-湘财.xls'),\n",
       " WindowsPath('stock_trades/202302-湘财.xls'),\n",
       " WindowsPath('stock_trades/202303-湘财.xls'),\n",
       " WindowsPath('stock_trades/202304-湘财.xls'),\n",
       " WindowsPath('stock_trades/202305-湘财.xls'),\n",
       " WindowsPath('stock_trades/202306-湘财.xls'),\n",
       " WindowsPath('stock_trades/202309-湘财.xls')]"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(Path(\"stock_trades/\").glob(\"*-湘财.xls\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "78bf113d-f114-48d1-93b1-a3fa68069260",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[WindowsPath('stock_trades/202207-湘财.xls'),\n",
       " WindowsPath('stock_trades/202208-湘财.xls'),\n",
       " WindowsPath('stock_trades/202209-湘财.xls'),\n",
       " WindowsPath('stock_trades/202210-湘财.xls'),\n",
       " WindowsPath('stock_trades/202211-湘财.xls'),\n",
       " WindowsPath('stock_trades/202212-湘财.xls'),\n",
       " WindowsPath('stock_trades/202301-湘财.xls'),\n",
       " WindowsPath('stock_trades/202302-湘财.xls'),\n",
       " WindowsPath('stock_trades/202303-湘财.xls'),\n",
       " WindowsPath('stock_trades/202304-湘财.xls'),\n",
       " WindowsPath('stock_trades/202305-湘财.xls'),\n",
       " WindowsPath('stock_trades/202306-湘财.xls'),\n",
       " WindowsPath('stock_trades/202309-湘财.xls')]"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[f for f in Path(\"stock_trades/\").glob(\"*-湘财.xls\")]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "60f6eaf5-c078-42eb-8a5a-72f3b23804b2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2633, 1242, 395, 5748, 2504, 2368, 3197, 5007, 7113, 7529, 4686, 1455, 563]"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[f.stat().st_size for f in Path(\"stock_trades/\").glob(\"*-湘财.xls\")]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "16cd7af3-f2d3-402d-9e80-d25ee81c1ec7",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    },
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'Path' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mNameError\u001b[39m                                 Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[1]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mread_df_湘财\u001b[39m(f: \u001b[38;5;28mstr\u001b[39m | \u001b[43mPath\u001b[49m) -> pl.DataFrame:\n\u001b[32m      2\u001b[39m     df = pl.read_csv(\n\u001b[32m      3\u001b[39m         f,\n\u001b[32m      4\u001b[39m         encoding=\u001b[33m\"\u001b[39m\u001b[33mgb18030\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m      5\u001b[39m         separator=\u001b[33m\"\u001b[39m\u001b[38;5;130;01m\\t\u001b[39;00m\u001b[33m\"\u001b[39m,\n\u001b[32m      6\u001b[39m         infer_schema=\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[32m      7\u001b[39m     )\n\u001b[32m      8\u001b[39m     df = df.with_columns(\n\u001b[32m      9\u001b[39m         pl.selectors.all().str.strip_prefix(\u001b[33m\"\u001b[39m\u001b[33m=\u001b[39m\u001b[33m\"\u001b[39m).str.strip_chars(\u001b[33m'\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m'\u001b[39m),\n\u001b[32m     10\u001b[39m     ).with_columns(\n\u001b[32m   (...)\u001b[39m\u001b[32m     22\u001b[39m         ).cast(pl.Float64),\n\u001b[32m     23\u001b[39m     )\n",
      "\u001b[31mNameError\u001b[39m: name 'Path' is not defined"
     ]
    }
   ],
   "source": [
    "def read_df_湘财(f: str | Path) -> pl.DataFrame:\n",
    "    df = pl.read_csv(\n",
    "        f,\n",
    "        encoding=\"gb18030\",\n",
    "        separator=\"\\t\",\n",
    "        infer_schema=False,\n",
    "    )\n",
    "    df = df.with_columns(\n",
    "        pl.selectors.all().str.strip_prefix(\"=\").str.strip_chars('\"'),\n",
    "    ).with_columns(\n",
    "        pl.col(\"发生日期\").str.to_date(\"%Y%m%d\"),\n",
    "        pl.col(\"成交时间\").str.to_time(),\n",
    "        pl.col(\n",
    "            \"成交数量\", \n",
    "            \"成交价格\", \n",
    "            \"成交金额\", \n",
    "            \"发生金额\", \n",
    "            \"手续费\", \n",
    "            \"印花税\", \n",
    "            \"过户费\", \n",
    "            \"其他费\"\n",
    "        ).cast(pl.Float64),\n",
    "    )\n",
    "    df = df.filter(\n",
    "        pl.col(\"业务名称\").is_in([\"证券买入\", \"证券卖出\"]),  \n",
    "    )\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "d749c8b8-a144-45ae-a39e-f5b93c8cf00d",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = [read_df_湘财(f) for f in Path(\"stock_trades/\").glob(\"*-湘财.xls\")]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "7b83e91e-23ad-4d45-841d-b98cc4275957",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "13"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "7524d1ce-622e-4db4-be3c-9240330bb94c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (13, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>time</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>2022-07-18</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>09:38:10</td><td>-10400.0</td><td>13.2062</td><td>137344.0</td><td>137184.67</td><td>21.98</td><td>137.35</td><td>1.38</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:44:52</td><td>47000.0</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>23.99</td><td>0.0</td><td>1.51</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:44:31</td><td>11900.0</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>24.0</td><td>0.0</td><td>1.49</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:43:38</td><td>40700.0</td><td>3.69</td><td>150183.0</td><td>-150208.53</td><td>24.03</td><td>0.0</td><td>1.5</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600015&quot;</td><td>&quot;华夏银行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:42:51</td><td>30000.0</td><td>5.07</td><td>152100.0</td><td>-152125.86</td><td>24.34</td><td>0.0</td><td>1.52</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>2022-07-11</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:38:16</td><td>10400.0</td><td>13.51</td><td>140504.0</td><td>-140526.48</td><td>22.48</td><td>0.0</td><td>1.41</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-11</td><td>&quot;000900&quot;</td><td>&quot;现代投资&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:33:37</td><td>34400.0</td><td>4.05</td><td>139320.0</td><td>-139342.29</td><td>22.29</td><td>0.0</td><td>1.39</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-11</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:37:25</td><td>54000.0</td><td>2.59</td><td>139860.0</td><td>-139883.8</td><td>22.38</td><td>0.0</td><td>1.42</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-11</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:36:30</td><td>21400.0</td><td>6.54</td><td>139956.0</td><td>-139979.8</td><td>22.39</td><td>0.0</td><td>1.41</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-11</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:34:24</td><td>38300.0</td><td>3.65</td><td>139795.0</td><td>-139818.75</td><td>22.37</td><td>0.0</td><td>1.38</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (13, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ f64    ┆ f64    ┆ str    ┆ str    │\n",
       "│ date    ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022-07 ┆ 002462  ┆ 嘉事堂  ┆ 卖出   ┆ … ┆ 1.38   ┆ 0.0    ┆ 证券卖 ┆ 人民币 │\n",
       "│ -18     ┆         ┆         ┆        ┆   ┆        ┆        ┆ 出     ┆        │\n",
       "│ 2022-07 ┆ 600408  ┆ 安泰集  ┆ 买入   ┆ … ┆ 1.51   ┆ 0.0    ┆ 证券买 ┆ 人民币 │\n",
       "│ -18     ┆         ┆ 团      ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 600648  ┆ 外高桥  ┆ 买入   ┆ … ┆ 1.49   ┆ 0.0    ┆ 证券买 ┆ 人民币 │\n",
       "│ -18     ┆         ┆         ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 600269  ┆ 赣粤高  ┆ 买入   ┆ … ┆ 1.5    ┆ 0.0    ┆ 证券买 ┆ 人民币 │\n",
       "│ -18     ┆         ┆ 速      ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 600015  ┆ 华夏银  ┆ 买入   ┆ … ┆ 1.52   ┆ 0.0    ┆ 证券买 ┆ 人民币 │\n",
       "│ -18     ┆         ┆ 行      ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 2022-07 ┆ 002462  ┆ 嘉事堂  ┆ 买入   ┆ … ┆ 1.41   ┆ 0.0    ┆ 证券买 ┆ 人民币 │\n",
       "│ -11     ┆         ┆         ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 000900  ┆ 现代投  ┆ 买入   ┆ … ┆ 1.39   ┆ 0.0    ┆ 证券买 ┆ 人民币 │\n",
       "│ -11     ┆         ┆ 资      ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 601992  ┆ 金隅集  ┆ 买入   ┆ … ┆ 1.42   ┆ 0.0    ┆ 证券买 ┆ 人民币 │\n",
       "│ -11     ┆         ┆ 团      ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 600894  ┆ 广日股  ┆ 买入   ┆ … ┆ 1.41   ┆ 0.0    ┆ 证券买 ┆ 人民币 │\n",
       "│ -11     ┆         ┆ 份      ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 601077  ┆ 渝农商  ┆ 买入   ┆ … ┆ 1.38   ┆ 0.0    ┆ 证券买 ┆ 人民币 │\n",
       "│ -11     ┆         ┆ 行      ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "id": "4c091e8b-ec40-4363-aa30-38955dfa03d4",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = pl.concat(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "e5558f1e-a179-4329-b1f1-75c7cf283fb2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (257, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>time</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>2022-07-18</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>09:38:10</td><td>-10400.0</td><td>13.2062</td><td>137344.0</td><td>137184.67</td><td>21.98</td><td>137.35</td><td>1.38</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:44:52</td><td>47000.0</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>23.99</td><td>0.0</td><td>1.51</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:44:31</td><td>11900.0</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>24.0</td><td>0.0</td><td>1.49</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:43:38</td><td>40700.0</td><td>3.69</td><td>150183.0</td><td>-150208.53</td><td>24.03</td><td>0.0</td><td>1.5</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600015&quot;</td><td>&quot;华夏银行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:42:51</td><td>30000.0</td><td>5.07</td><td>152100.0</td><td>-152125.86</td><td>24.34</td><td>0.0</td><td>1.52</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>2023-06-19</td><td>&quot;603967&quot;</td><td>&quot;中创物流&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>10:18:46</td><td>-5000.0</td><td>9.13</td><td>45650.0</td><td>45596.59</td><td>7.3</td><td>45.65</td><td>0.46</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2023-06-12</td><td>&quot;300641&quot;</td><td>&quot;正丹股份&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>13:22:32</td><td>-9600.0</td><td>5.05</td><td>48480.0</td><td>48423.76</td><td>7.76</td><td>48.48</td><td>0.48</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2023-06-02</td><td>&quot;000655&quot;</td><td>&quot;金岭矿业&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>10:26:35</td><td>-7500.0</td><td>6.48</td><td>48600.0</td><td>48543.61</td><td>7.78</td><td>48.61</td><td>0.47</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2023-06-01</td><td>&quot;300214&quot;</td><td>&quot;日科化学&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>10:45:35</td><td>-7400.0</td><td>6.8</td><td>50320.0</td><td>50261.63</td><td>8.05</td><td>50.32</td><td>0.51</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>2023-09-11</td><td>&quot;603577&quot;</td><td>&quot;汇金通&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>09:46:10</td><td>-5100.0</td><td>9.3024</td><td>47442.0</td><td>47410.89</td><td>6.9</td><td>23.72</td><td>0.49</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (257, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 币种   │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ f64    ┆ f64    ┆ str    ┆ str    │\n",
       "│ date    ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 2022-07 ┆ 002462  ┆ 嘉事堂  ┆ 卖出   ┆ … ┆ 1.38   ┆ 0.0    ┆ 证券卖 ┆ 人民币 │\n",
       "│ -18     ┆         ┆         ┆        ┆   ┆        ┆        ┆ 出     ┆        │\n",
       "│ 2022-07 ┆ 600408  ┆ 安泰集  ┆ 买入   ┆ … ┆ 1.51   ┆ 0.0    ┆ 证券买 ┆ 人民币 │\n",
       "│ -18     ┆         ┆ 团      ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 600648  ┆ 外高桥  ┆ 买入   ┆ … ┆ 1.49   ┆ 0.0    ┆ 证券买 ┆ 人民币 │\n",
       "│ -18     ┆         ┆         ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 600269  ┆ 赣粤高  ┆ 买入   ┆ … ┆ 1.5    ┆ 0.0    ┆ 证券买 ┆ 人民币 │\n",
       "│ -18     ┆         ┆ 速      ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "│ 2022-07 ┆ 600015  ┆ 华夏银  ┆ 买入   ┆ … ┆ 1.52   ┆ 0.0    ┆ 证券买 ┆ 人民币 │\n",
       "│ -18     ┆         ┆ 行      ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 2023-06 ┆ 603967  ┆ 中创物  ┆ 卖出   ┆ … ┆ 0.46   ┆ 0.0    ┆ 证券卖 ┆ 人民币 │\n",
       "│ -19     ┆         ┆ 流      ┆        ┆   ┆        ┆        ┆ 出     ┆        │\n",
       "│ 2023-06 ┆ 300641  ┆ 正丹股  ┆ 卖出   ┆ … ┆ 0.48   ┆ 0.0    ┆ 证券卖 ┆ 人民币 │\n",
       "│ -12     ┆         ┆ 份      ┆        ┆   ┆        ┆        ┆ 出     ┆        │\n",
       "│ 2023-06 ┆ 000655  ┆ 金岭矿  ┆ 卖出   ┆ … ┆ 0.47   ┆ 0.0    ┆ 证券卖 ┆ 人民币 │\n",
       "│ -02     ┆         ┆ 业      ┆        ┆   ┆        ┆        ┆ 出     ┆        │\n",
       "│ 2023-06 ┆ 300214  ┆ 日科化  ┆ 卖出   ┆ … ┆ 0.51   ┆ 0.0    ┆ 证券卖 ┆ 人民币 │\n",
       "│ -01     ┆         ┆ 学      ┆        ┆   ┆        ┆        ┆ 出     ┆        │\n",
       "│ 2023-09 ┆ 603577  ┆ 汇金通  ┆ 卖出   ┆ … ┆ 0.49   ┆ 0.0    ┆ 证券卖 ┆ 人民币 │\n",
       "│ -11     ┆         ┆         ┆        ┆   ┆        ┆        ┆ 出     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "9c1893a9-1a79-470d-b1a1-e2d44e9fd235",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = d1.with_columns(\n",
    "    券商=pl.lit(\"湘财\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "id": "10a91636-3c96-40bc-8c49-fb8a21cbb470",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (257, 17)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th><th>券商</th></tr><tr><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>time</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>2022-07-18</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>09:38:10</td><td>-10400.0</td><td>13.2062</td><td>137344.0</td><td>137184.67</td><td>21.98</td><td>137.35</td><td>1.38</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:44:52</td><td>47000.0</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>23.99</td><td>0.0</td><td>1.51</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:44:31</td><td>11900.0</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>24.0</td><td>0.0</td><td>1.49</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:43:38</td><td>40700.0</td><td>3.69</td><td>150183.0</td><td>-150208.53</td><td>24.03</td><td>0.0</td><td>1.5</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600015&quot;</td><td>&quot;华夏银行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:42:51</td><td>30000.0</td><td>5.07</td><td>152100.0</td><td>-152125.86</td><td>24.34</td><td>0.0</td><td>1.52</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>2023-06-19</td><td>&quot;603967&quot;</td><td>&quot;中创物流&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>10:18:46</td><td>-5000.0</td><td>9.13</td><td>45650.0</td><td>45596.59</td><td>7.3</td><td>45.65</td><td>0.46</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2023-06-12</td><td>&quot;300641&quot;</td><td>&quot;正丹股份&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>13:22:32</td><td>-9600.0</td><td>5.05</td><td>48480.0</td><td>48423.76</td><td>7.76</td><td>48.48</td><td>0.48</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2023-06-02</td><td>&quot;000655&quot;</td><td>&quot;金岭矿业&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>10:26:35</td><td>-7500.0</td><td>6.48</td><td>48600.0</td><td>48543.61</td><td>7.78</td><td>48.61</td><td>0.47</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2023-06-01</td><td>&quot;300214&quot;</td><td>&quot;日科化学&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>10:45:35</td><td>-7400.0</td><td>6.8</td><td>50320.0</td><td>50261.63</td><td>8.05</td><td>50.32</td><td>0.51</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2023-09-11</td><td>&quot;603577&quot;</td><td>&quot;汇金通&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>09:46:10</td><td>-5100.0</td><td>9.3024</td><td>47442.0</td><td>47410.89</td><td>6.9</td><td>23.72</td><td>0.49</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (257, 17)\n",
       "┌─────────┬─────────┬─────────┬─────────┬───┬────────┬─────────┬────────┬──────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标  ┆ … ┆ 其他费 ┆ 备注    ┆ 币种   ┆ 券商 │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志      ┆   ┆ ---    ┆ ---     ┆ ---    ┆ ---  │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---     ┆   ┆ f64    ┆ str     ┆ str    ┆ str  │\n",
       "│ date    ┆ str     ┆ str     ┆ str     ┆   ┆        ┆         ┆        ┆      │\n",
       "╞═════════╪═════════╪═════════╪═════════╪═══╪════════╪═════════╪════════╪══════╡\n",
       "│ 2022-07 ┆ 002462  ┆ 嘉事堂  ┆ 卖出    ┆ … ┆ 0.0    ┆ 证券卖  ┆ 人民币 ┆ 湘财 │\n",
       "│ -18     ┆         ┆         ┆         ┆   ┆        ┆ 出      ┆        ┆      │\n",
       "│ 2022-07 ┆ 600408  ┆ 安泰集  ┆ 买入    ┆ … ┆ 0.0    ┆ 证券买  ┆ 人民币 ┆ 湘财 │\n",
       "│ -18     ┆         ┆ 团      ┆         ┆   ┆        ┆ 入      ┆        ┆      │\n",
       "│ 2022-07 ┆ 600648  ┆ 外高桥  ┆ 买入    ┆ … ┆ 0.0    ┆ 证券买  ┆ 人民币 ┆ 湘财 │\n",
       "│ -18     ┆         ┆         ┆         ┆   ┆        ┆ 入      ┆        ┆      │\n",
       "│ 2022-07 ┆ 600269  ┆ 赣粤高  ┆ 买入    ┆ … ┆ 0.0    ┆ 证券买  ┆ 人民币 ┆ 湘财 │\n",
       "│ -18     ┆         ┆ 速      ┆         ┆   ┆        ┆ 入      ┆        ┆      │\n",
       "│ 2022-07 ┆ 600015  ┆ 华夏银  ┆ 买入    ┆ … ┆ 0.0    ┆ 证券买  ┆ 人民币 ┆ 湘财 │\n",
       "│ -18     ┆         ┆ 行      ┆         ┆   ┆        ┆ 入      ┆        ┆      │\n",
       "│ …       ┆ …       ┆ …       ┆ …       ┆ … ┆ …      ┆ …       ┆ …      ┆ …    │\n",
       "│ 2023-06 ┆ 603967  ┆ 中创物  ┆ 卖出    ┆ … ┆ 0.0    ┆ 证券卖  ┆ 人民币 ┆ 湘财 │\n",
       "│ -19     ┆         ┆ 流      ┆         ┆   ┆        ┆ 出      ┆        ┆      │\n",
       "│ 2023-06 ┆ 300641  ┆ 正丹股  ┆ 卖出    ┆ … ┆ 0.0    ┆ 证券卖  ┆ 人民币 ┆ 湘财 │\n",
       "│ -12     ┆         ┆ 份      ┆         ┆   ┆        ┆ 出      ┆        ┆      │\n",
       "│ 2023-06 ┆ 000655  ┆ 金岭矿  ┆ 卖出    ┆ … ┆ 0.0    ┆ 证券卖  ┆ 人民币 ┆ 湘财 │\n",
       "│ -02     ┆         ┆ 业      ┆         ┆   ┆        ┆ 出      ┆        ┆      │\n",
       "│ 2023-06 ┆ 300214  ┆ 日科化  ┆ 卖出    ┆ … ┆ 0.0    ┆ 证券卖  ┆ 人民币 ┆ 湘财 │\n",
       "│ -01     ┆         ┆ 学      ┆         ┆   ┆        ┆ 出      ┆        ┆      │\n",
       "│ 2023-09 ┆ 603577  ┆ 汇金通  ┆ 卖出    ┆ … ┆ 0.0    ┆ 证券卖  ┆ 人民币 ┆ 湘财 │\n",
       "│ -11     ┆         ┆         ┆         ┆   ┆        ┆ 出      ┆        ┆      │\n",
       "└─────────┴─────────┴─────────┴─────────┴───┴────────┴─────────┴────────┴──────┘"
      ]
     },
     "execution_count": 114,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "id": "80c5e9be-bd4b-461e-97de-41cdc8f89112",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (6, 14)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th></tr><tr><td>str</td><td>str</td><td>date</td><td>time</td><td>i64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>i64</td><td>f64</td><td>i64</td><td>str</td></tr></thead><tbody><tr><td>&quot;600626&quot;</td><td>&quot;申达股份&quot;</td><td>2023-05-24</td><td>10:06:14</td><td>14800</td><td>3.37</td><td>49876.0</td><td>-49881.48</td><td>&quot;买&quot;</td><td>4.99</td><td>0</td><td>0.49</td><td>0</td><td>&quot;申达股份证券买入&quot;</td></tr><tr><td>&quot;600178&quot;</td><td>&quot;东安动力&quot;</td><td>2023-05-24</td><td>09:59:17</td><td>16400</td><td>6.07</td><td>99548.0</td><td>-99558.97</td><td>&quot;买&quot;</td><td>9.95</td><td>0</td><td>1.02</td><td>0</td><td>&quot;东安动力证券买入&quot;</td></tr><tr><td>&quot;603002&quot;</td><td>&quot;宏昌电子&quot;</td><td>2023-05-24</td><td>09:54:48</td><td>9800</td><td>5.06</td><td>49588.0</td><td>-49593.46</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.5</td><td>0</td><td>&quot;宏昌电子证券买入&quot;</td></tr><tr><td>&quot;131810&quot;</td><td>&quot;Ｒ-001&quot;</td><td>2023-05-23</td><td>10:05:49</td><td>1500</td><td>1.865</td><td>150000.0</td><td>-150001.5</td><td>&quot;卖&quot;</td><td>1.5</td><td>0</td><td>0.0</td><td>0</td><td>&quot;到期日[20230524]，利息[7.66]，金额[1500…</td></tr><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>2023-05-23</td><td>10:01:57</td><td>10000</td><td>5.0</td><td>50000.0</td><td>-50005.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;建新股份证券买入&quot;</td></tr><tr><td>&quot;002224&quot;</td><td>&quot;三 力 士&quot;</td><td>2023-05-23</td><td>09:58:07</td><td>10800</td><td>4.59</td><td>49572.0</td><td>-49576.96</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.0</td><td>0</td><td>&quot;三 力 士证券买入&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (6, 14)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 证券代  ┆ 证券名  ┆ 成交日  ┆ 成交时 ┆ … ┆ 印花税 ┆ 过户费 ┆ 其他费 ┆ 备注   │\n",
       "│ 码      ┆ 称      ┆ 期      ┆ 间     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ i64    ┆ f64    ┆ i64    ┆ str    │\n",
       "│ str     ┆ str     ┆ date    ┆ time   ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 600626  ┆ 申达股  ┆ 2023-05 ┆ 10:06: ┆ … ┆ 0      ┆ 0.49   ┆ 0      ┆ 申达股 │\n",
       "│         ┆ 份      ┆ -24     ┆ 14     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 600178  ┆ 东安动  ┆ 2023-05 ┆ 09:59: ┆ … ┆ 0      ┆ 1.02   ┆ 0      ┆ 东安动 │\n",
       "│         ┆ 力      ┆ -24     ┆ 17     ┆   ┆        ┆        ┆        ┆ 力证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 603002  ┆ 宏昌电  ┆ 2023-05 ┆ 09:54: ┆ … ┆ 0      ┆ 0.5    ┆ 0      ┆ 宏昌电 │\n",
       "│         ┆ 子      ┆ -24     ┆ 48     ┆   ┆        ┆        ┆        ┆ 子证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 131810  ┆ Ｒ-001  ┆ 2023-05 ┆ 10:05: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 到期日 │\n",
       "│         ┆         ┆ -23     ┆ 49     ┆   ┆        ┆        ┆        ┆ [20230 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 524]， │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 利息[7 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ .66]， │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 金额[1 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 500…   │\n",
       "│ 300107  ┆ 建新股  ┆ 2023-05 ┆ 10:01: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 建新股 │\n",
       "│         ┆ 份      ┆ -23     ┆ 57     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 002224  ┆ 三 力   ┆ 2023-05 ┆ 09:58: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 三 力  │\n",
       "│         ┆ 士      ┆ -23     ┆ 07     ┆   ┆        ┆        ┆        ┆ 士证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 136,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pl.read_excel(\n",
    "    \"stock_trades/202305-海通普通.xlsx\",\n",
    "    schema_overrides={\n",
    "    \"成交日期\": pl.String,\n",
    "    \"成交时间\":pl. String,\n",
    "    },\n",
    ")\n",
    "df.filter( pl.col(\"成交时间\")!=\"\").filter(\n",
    "    pl.col(\"操作\").is_in([\"买\",\"卖\"])\n",
    ").with_columns(\n",
    "    pl.col(\"成交日期\").str.to_date(\"%Y%m%d\"),\n",
    "    pl.col(\"成交时间\").str.to_time(\"%H:%M:%S\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "id": "f2f37ecc-1bf6-455b-a54a-a19489007e7d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (5, 14)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th></tr><tr><td>str</td><td>str</td><td>date</td><td>time</td><td>i64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>i64</td><td>f64</td><td>i64</td><td>str</td></tr></thead><tbody><tr><td>&quot;600626&quot;</td><td>&quot;申达股份&quot;</td><td>2023-05-24</td><td>10:06:14</td><td>14800</td><td>3.37</td><td>49876.0</td><td>-49881.48</td><td>&quot;买&quot;</td><td>4.99</td><td>0</td><td>0.49</td><td>0</td><td>&quot;申达股份证券买入&quot;</td></tr><tr><td>&quot;600178&quot;</td><td>&quot;东安动力&quot;</td><td>2023-05-24</td><td>09:59:17</td><td>16400</td><td>6.07</td><td>99548.0</td><td>-99558.97</td><td>&quot;买&quot;</td><td>9.95</td><td>0</td><td>1.02</td><td>0</td><td>&quot;东安动力证券买入&quot;</td></tr><tr><td>&quot;603002&quot;</td><td>&quot;宏昌电子&quot;</td><td>2023-05-24</td><td>09:54:48</td><td>9800</td><td>5.06</td><td>49588.0</td><td>-49593.46</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.5</td><td>0</td><td>&quot;宏昌电子证券买入&quot;</td></tr><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>2023-05-23</td><td>10:01:57</td><td>10000</td><td>5.0</td><td>50000.0</td><td>-50005.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;建新股份证券买入&quot;</td></tr><tr><td>&quot;002224&quot;</td><td>&quot;三 力 士&quot;</td><td>2023-05-23</td><td>09:58:07</td><td>10800</td><td>4.59</td><td>49572.0</td><td>-49576.96</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.0</td><td>0</td><td>&quot;三 力 士证券买入&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (5, 14)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 证券代  ┆ 证券名  ┆ 成交日  ┆ 成交时 ┆ … ┆ 印花税 ┆ 过户费 ┆ 其他费 ┆ 备注   │\n",
       "│ 码      ┆ 称      ┆ 期      ┆ 间     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ i64    ┆ f64    ┆ i64    ┆ str    │\n",
       "│ str     ┆ str     ┆ date    ┆ time   ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 600626  ┆ 申达股  ┆ 2023-05 ┆ 10:06: ┆ … ┆ 0      ┆ 0.49   ┆ 0      ┆ 申达股 │\n",
       "│         ┆ 份      ┆ -24     ┆ 14     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 600178  ┆ 东安动  ┆ 2023-05 ┆ 09:59: ┆ … ┆ 0      ┆ 1.02   ┆ 0      ┆ 东安动 │\n",
       "│         ┆ 力      ┆ -24     ┆ 17     ┆   ┆        ┆        ┆        ┆ 力证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 603002  ┆ 宏昌电  ┆ 2023-05 ┆ 09:54: ┆ … ┆ 0      ┆ 0.5    ┆ 0      ┆ 宏昌电 │\n",
       "│         ┆ 子      ┆ -24     ┆ 48     ┆   ┆        ┆        ┆        ┆ 子证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 300107  ┆ 建新股  ┆ 2023-05 ┆ 10:01: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 建新股 │\n",
       "│         ┆ 份      ┆ -23     ┆ 57     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 002224  ┆ 三 力   ┆ 2023-05 ┆ 09:58: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 三 力  │\n",
       "│         ┆ 士      ┆ -23     ┆ 07     ┆   ┆        ┆        ┆        ┆ 士证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 139,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pl.read_excel(\n",
    "    \"stock_trades/202305-海通普通.xlsx\",\n",
    "    schema_overrides={\n",
    "    \"成交日期\": pl.String,\n",
    "    \"成交时间\":pl. String,\n",
    "    },\n",
    ")\n",
    "df.filter( pl.col(\"成交时间\")!=\"\").filter(\n",
    "    pl.col(\"操作\").is_in([\"买\",\"卖\"])\n",
    ").filter(\n",
    "    (~pl.col(\"证券代码\").str.starts_with(\"204\")) &\n",
    "    (~pl.col(\"证券代码\").str.starts_with(\"1318\"))\n",
    ").with_columns(\n",
    "    pl.col(\"成交日期\").str.to_date(\"%Y%m%d\"),\n",
    "    pl.col(\"成交时间\").str.to_time(\"%H:%M:%S\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "id": "197d553c-88c1-4160-a62b-76f9418765a3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[WindowsPath('stock_trades/202305-海通普通.xlsx'),\n",
       " WindowsPath('stock_trades/202306-海通普通.xlsx'),\n",
       " WindowsPath('stock_trades/202307-海通普通.xlsx')]"
      ]
     },
     "execution_count": 140,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(Path(\"stock_trades/\").glob(\"*-海通普通.xlsx\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "id": "f6142f3e-7f2f-4b90-bbbd-5d433130c5d1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (5, 14)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th></tr><tr><td>str</td><td>str</td><td>date</td><td>time</td><td>i64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>i64</td><td>f64</td><td>i64</td><td>str</td></tr></thead><tbody><tr><td>&quot;600626&quot;</td><td>&quot;申达股份&quot;</td><td>2023-05-24</td><td>10:06:14</td><td>14800</td><td>3.37</td><td>49876.0</td><td>-49881.48</td><td>&quot;买&quot;</td><td>4.99</td><td>0</td><td>0.49</td><td>0</td><td>&quot;申达股份证券买入&quot;</td></tr><tr><td>&quot;600178&quot;</td><td>&quot;东安动力&quot;</td><td>2023-05-24</td><td>09:59:17</td><td>16400</td><td>6.07</td><td>99548.0</td><td>-99558.97</td><td>&quot;买&quot;</td><td>9.95</td><td>0</td><td>1.02</td><td>0</td><td>&quot;东安动力证券买入&quot;</td></tr><tr><td>&quot;603002&quot;</td><td>&quot;宏昌电子&quot;</td><td>2023-05-24</td><td>09:54:48</td><td>9800</td><td>5.06</td><td>49588.0</td><td>-49593.46</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.5</td><td>0</td><td>&quot;宏昌电子证券买入&quot;</td></tr><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>2023-05-23</td><td>10:01:57</td><td>10000</td><td>5.0</td><td>50000.0</td><td>-50005.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;建新股份证券买入&quot;</td></tr><tr><td>&quot;002224&quot;</td><td>&quot;三 力 士&quot;</td><td>2023-05-23</td><td>09:58:07</td><td>10800</td><td>4.59</td><td>49572.0</td><td>-49576.96</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.0</td><td>0</td><td>&quot;三 力 士证券买入&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (5, 14)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 证券代  ┆ 证券名  ┆ 成交日  ┆ 成交时 ┆ … ┆ 印花税 ┆ 过户费 ┆ 其他费 ┆ 备注   │\n",
       "│ 码      ┆ 称      ┆ 期      ┆ 间     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ i64    ┆ f64    ┆ i64    ┆ str    │\n",
       "│ str     ┆ str     ┆ date    ┆ time   ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 600626  ┆ 申达股  ┆ 2023-05 ┆ 10:06: ┆ … ┆ 0      ┆ 0.49   ┆ 0      ┆ 申达股 │\n",
       "│         ┆ 份      ┆ -24     ┆ 14     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 600178  ┆ 东安动  ┆ 2023-05 ┆ 09:59: ┆ … ┆ 0      ┆ 1.02   ┆ 0      ┆ 东安动 │\n",
       "│         ┆ 力      ┆ -24     ┆ 17     ┆   ┆        ┆        ┆        ┆ 力证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 603002  ┆ 宏昌电  ┆ 2023-05 ┆ 09:54: ┆ … ┆ 0      ┆ 0.5    ┆ 0      ┆ 宏昌电 │\n",
       "│         ┆ 子      ┆ -24     ┆ 48     ┆   ┆        ┆        ┆        ┆ 子证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 300107  ┆ 建新股  ┆ 2023-05 ┆ 10:01: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 建新股 │\n",
       "│         ┆ 份      ┆ -23     ┆ 57     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 002224  ┆ 三 力   ┆ 2023-05 ┆ 09:58: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 三 力  │\n",
       "│         ┆ 士      ┆ -23     ┆ 07     ┆   ┆        ┆        ┆        ┆ 士证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 161,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def read_df_海通普通(f: str | Path) -> pl.DataFrame:\n",
    "    df = pl.read_excel(\n",
    "         \"stock_trades/202305-海通普通.xlsx\",\n",
    "         schema_overrides={\n",
    "             \"成交日期\": pl.String,\n",
    "             \"成交时间\":pl. String,\n",
    "         },\n",
    "    )\n",
    "    df = (\n",
    "       df.filter(\n",
    "           (pl.col(\"成交时间\")!=\"\")\n",
    "           &(pl.col(\"操作\").is_in([\"买\",\"卖\"]))\n",
    "           &(~pl.col(\"证券代码\").str.starts_with(\"204\"))\n",
    "           &(~pl.col(\"证券代码\").str.starts_with(\"1318\"))\n",
    "        ).with_columns(\n",
    "            pl.col(\"成交日期\").str.to_date(\"%Y%m%d\"),\n",
    "            pl.col(\"成交时间\").str.to_time(\"%H:%M:%S\"),\n",
    "        )\n",
    "   )\n",
    "    return df\n",
    "read_df_海通普通(\"stock_trades/202305-海通普通.xlsx\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 142,
   "id": "00247e8b-b65a-437c-9ea6-157902c8c333",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = [read_df_海通普通(p) for p in Path(\"stock_trades/\").glob(\"*-海通普通.xlsx\")]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 143,
   "id": "270ae9b1-a188-49b4-874f-e4b884172812",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 143,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "id": "1fedb11e-97d1-49e4-a776-73ca9ab8a7e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (10, 14)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th></tr><tr><td>str</td><td>str</td><td>str</td><td>str</td><td>i64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>i64</td><td>f64</td><td>i64</td><td>str</td></tr></thead><tbody><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>&quot;20230529&quot;</td><td>&quot;&quot;</td><td>0</td><td>0.0</td><td>600.0</td><td>600.0</td><td>&quot;卖&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;建新股份,深圳现金红利&quot;</td></tr><tr><td>&quot;131810&quot;</td><td>&quot;Ｒ-001&quot;</td><td>&quot;20230524&quot;</td><td>&quot;&quot;</td><td>1500</td><td>100.005</td><td>150007.66</td><td>150007.66</td><td>&quot;买&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;Ｒ-001,拆出购回&quot;</td></tr><tr><td>&quot;799999&quot;</td><td>&quot;指定登记&quot;</td><td>&quot;20230524&quot;</td><td>&quot;15:00:00&quot;</td><td>0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;指&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;指定登记指定交易&quot;</td></tr><tr><td>&quot;600626&quot;</td><td>&quot;申达股份&quot;</td><td>&quot;20230524&quot;</td><td>&quot;10:06:14&quot;</td><td>14800</td><td>3.37</td><td>49876.0</td><td>-49881.48</td><td>&quot;买&quot;</td><td>4.99</td><td>0</td><td>0.49</td><td>0</td><td>&quot;申达股份证券买入&quot;</td></tr><tr><td>&quot;600178&quot;</td><td>&quot;东安动力&quot;</td><td>&quot;20230524&quot;</td><td>&quot;09:59:17&quot;</td><td>16400</td><td>6.07</td><td>99548.0</td><td>-99558.97</td><td>&quot;买&quot;</td><td>9.95</td><td>0</td><td>1.02</td><td>0</td><td>&quot;东安动力证券买入&quot;</td></tr><tr><td>&quot;603002&quot;</td><td>&quot;宏昌电子&quot;</td><td>&quot;20230524&quot;</td><td>&quot;09:54:48&quot;</td><td>9800</td><td>5.06</td><td>49588.0</td><td>-49593.46</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.5</td><td>0</td><td>&quot;宏昌电子证券买入&quot;</td></tr><tr><td>&quot;131810&quot;</td><td>&quot;Ｒ-001&quot;</td><td>&quot;20230523&quot;</td><td>&quot;10:05:49&quot;</td><td>1500</td><td>1.865</td><td>150000.0</td><td>-150001.5</td><td>&quot;卖&quot;</td><td>1.5</td><td>0</td><td>0.0</td><td>0</td><td>&quot;到期日[20230524]，利息[7.66]，金额[1500…</td></tr><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>&quot;20230523&quot;</td><td>&quot;10:01:57&quot;</td><td>10000</td><td>5.0</td><td>50000.0</td><td>-50005.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;建新股份证券买入&quot;</td></tr><tr><td>&quot;002224&quot;</td><td>&quot;三 力 士&quot;</td><td>&quot;20230523&quot;</td><td>&quot;09:58:07&quot;</td><td>10800</td><td>4.59</td><td>49572.0</td><td>-49576.96</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.0</td><td>0</td><td>&quot;三 力 士证券买入&quot;</td></tr><tr><td>&quot;799998&quot;</td><td>&quot;指定撤销&quot;</td><td>&quot;20230522&quot;</td><td>&quot;15:00:00&quot;</td><td>0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;撤&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;指定撤销撤消指定&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (10, 14)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 证券代  ┆ 证券名  ┆ 成交日  ┆ 成交时 ┆ … ┆ 印花税 ┆ 过户费 ┆ 其他费 ┆ 备注   │\n",
       "│ 码      ┆ 称      ┆ 期      ┆ 间     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ i64    ┆ f64    ┆ i64    ┆ str    │\n",
       "│ str     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 300107  ┆ 建新股  ┆ 2023052 ┆        ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 建新股 │\n",
       "│         ┆ 份      ┆ 9       ┆        ┆   ┆        ┆        ┆        ┆ 份,深  │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 圳现金 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 红利   │\n",
       "│ 131810  ┆ Ｒ-001  ┆ 2023052 ┆        ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ Ｒ-001 │\n",
       "│         ┆         ┆ 4       ┆        ┆   ┆        ┆        ┆        ┆ ,拆出  │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 购回   │\n",
       "│ 799999  ┆ 指定登  ┆ 2023052 ┆ 15:00: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 指定登 │\n",
       "│         ┆ 记      ┆ 4       ┆ 00     ┆   ┆        ┆        ┆        ┆ 记指定 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 交易   │\n",
       "│ 600626  ┆ 申达股  ┆ 2023052 ┆ 10:06: ┆ … ┆ 0      ┆ 0.49   ┆ 0      ┆ 申达股 │\n",
       "│         ┆ 份      ┆ 4       ┆ 14     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 600178  ┆ 东安动  ┆ 2023052 ┆ 09:59: ┆ … ┆ 0      ┆ 1.02   ┆ 0      ┆ 东安动 │\n",
       "│         ┆ 力      ┆ 4       ┆ 17     ┆   ┆        ┆        ┆        ┆ 力证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 603002  ┆ 宏昌电  ┆ 2023052 ┆ 09:54: ┆ … ┆ 0      ┆ 0.5    ┆ 0      ┆ 宏昌电 │\n",
       "│         ┆ 子      ┆ 4       ┆ 48     ┆   ┆        ┆        ┆        ┆ 子证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 131810  ┆ Ｒ-001  ┆ 2023052 ┆ 10:05: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 到期日 │\n",
       "│         ┆         ┆ 3       ┆ 49     ┆   ┆        ┆        ┆        ┆ [20230 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 524]， │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 利息[7 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ .66]， │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 金额[1 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 500…   │\n",
       "│ 300107  ┆ 建新股  ┆ 2023052 ┆ 10:01: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 建新股 │\n",
       "│         ┆ 份      ┆ 3       ┆ 57     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 002224  ┆ 三 力   ┆ 2023052 ┆ 09:58: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 三 力  │\n",
       "│         ┆ 士      ┆ 3       ┆ 07     ┆   ┆        ┆        ┆        ┆ 士证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 799998  ┆ 指定撤  ┆ 2023052 ┆ 15:00: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 指定撤 │\n",
       "│         ┆ 销      ┆ 2       ┆ 00     ┆   ┆        ┆        ┆        ┆ 销撤消 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 指定   │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 144,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "id": "fe070216-8cec-4995-ac79-67fee658dcb5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (30, 14)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th></tr><tr><td>str</td><td>str</td><td>str</td><td>str</td><td>i64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>i64</td><td>f64</td><td>i64</td><td>str</td></tr></thead><tbody><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>&quot;20230529&quot;</td><td>&quot;&quot;</td><td>0</td><td>0.0</td><td>600.0</td><td>600.0</td><td>&quot;卖&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;建新股份,深圳现金红利&quot;</td></tr><tr><td>&quot;131810&quot;</td><td>&quot;Ｒ-001&quot;</td><td>&quot;20230524&quot;</td><td>&quot;&quot;</td><td>1500</td><td>100.005</td><td>150007.66</td><td>150007.66</td><td>&quot;买&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;Ｒ-001,拆出购回&quot;</td></tr><tr><td>&quot;799999&quot;</td><td>&quot;指定登记&quot;</td><td>&quot;20230524&quot;</td><td>&quot;15:00:00&quot;</td><td>0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;指&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;指定登记指定交易&quot;</td></tr><tr><td>&quot;600626&quot;</td><td>&quot;申达股份&quot;</td><td>&quot;20230524&quot;</td><td>&quot;10:06:14&quot;</td><td>14800</td><td>3.37</td><td>49876.0</td><td>-49881.48</td><td>&quot;买&quot;</td><td>4.99</td><td>0</td><td>0.49</td><td>0</td><td>&quot;申达股份证券买入&quot;</td></tr><tr><td>&quot;600178&quot;</td><td>&quot;东安动力&quot;</td><td>&quot;20230524&quot;</td><td>&quot;09:59:17&quot;</td><td>16400</td><td>6.07</td><td>99548.0</td><td>-99558.97</td><td>&quot;买&quot;</td><td>9.95</td><td>0</td><td>1.02</td><td>0</td><td>&quot;东安动力证券买入&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;603002&quot;</td><td>&quot;宏昌电子&quot;</td><td>&quot;20230524&quot;</td><td>&quot;09:54:48&quot;</td><td>9800</td><td>5.06</td><td>49588.0</td><td>-49593.46</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.5</td><td>0</td><td>&quot;宏昌电子证券买入&quot;</td></tr><tr><td>&quot;131810&quot;</td><td>&quot;Ｒ-001&quot;</td><td>&quot;20230523&quot;</td><td>&quot;10:05:49&quot;</td><td>1500</td><td>1.865</td><td>150000.0</td><td>-150001.5</td><td>&quot;卖&quot;</td><td>1.5</td><td>0</td><td>0.0</td><td>0</td><td>&quot;到期日[20230524]，利息[7.66]，金额[1500…</td></tr><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>&quot;20230523&quot;</td><td>&quot;10:01:57&quot;</td><td>10000</td><td>5.0</td><td>50000.0</td><td>-50005.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;建新股份证券买入&quot;</td></tr><tr><td>&quot;002224&quot;</td><td>&quot;三 力 士&quot;</td><td>&quot;20230523&quot;</td><td>&quot;09:58:07&quot;</td><td>10800</td><td>4.59</td><td>49572.0</td><td>-49576.96</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.0</td><td>0</td><td>&quot;三 力 士证券买入&quot;</td></tr><tr><td>&quot;799998&quot;</td><td>&quot;指定撤销&quot;</td><td>&quot;20230522&quot;</td><td>&quot;15:00:00&quot;</td><td>0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;撤&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;指定撤销撤消指定&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (30, 14)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 证券代  ┆ 证券名  ┆ 成交日  ┆ 成交时 ┆ … ┆ 印花税 ┆ 过户费 ┆ 其他费 ┆ 备注   │\n",
       "│ 码      ┆ 称      ┆ 期      ┆ 间     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ i64    ┆ f64    ┆ i64    ┆ str    │\n",
       "│ str     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 300107  ┆ 建新股  ┆ 2023052 ┆        ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 建新股 │\n",
       "│         ┆ 份      ┆ 9       ┆        ┆   ┆        ┆        ┆        ┆ 份,深  │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 圳现金 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 红利   │\n",
       "│ 131810  ┆ Ｒ-001  ┆ 2023052 ┆        ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ Ｒ-001 │\n",
       "│         ┆         ┆ 4       ┆        ┆   ┆        ┆        ┆        ┆ ,拆出  │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 购回   │\n",
       "│ 799999  ┆ 指定登  ┆ 2023052 ┆ 15:00: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 指定登 │\n",
       "│         ┆ 记      ┆ 4       ┆ 00     ┆   ┆        ┆        ┆        ┆ 记指定 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 交易   │\n",
       "│ 600626  ┆ 申达股  ┆ 2023052 ┆ 10:06: ┆ … ┆ 0      ┆ 0.49   ┆ 0      ┆ 申达股 │\n",
       "│         ┆ 份      ┆ 4       ┆ 14     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 600178  ┆ 东安动  ┆ 2023052 ┆ 09:59: ┆ … ┆ 0      ┆ 1.02   ┆ 0      ┆ 东安动 │\n",
       "│         ┆ 力      ┆ 4       ┆ 17     ┆   ┆        ┆        ┆        ┆ 力证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 603002  ┆ 宏昌电  ┆ 2023052 ┆ 09:54: ┆ … ┆ 0      ┆ 0.5    ┆ 0      ┆ 宏昌电 │\n",
       "│         ┆ 子      ┆ 4       ┆ 48     ┆   ┆        ┆        ┆        ┆ 子证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 131810  ┆ Ｒ-001  ┆ 2023052 ┆ 10:05: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 到期日 │\n",
       "│         ┆         ┆ 3       ┆ 49     ┆   ┆        ┆        ┆        ┆ [20230 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 524]， │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 利息[7 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ .66]， │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 金额[1 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 500…   │\n",
       "│ 300107  ┆ 建新股  ┆ 2023052 ┆ 10:01: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 建新股 │\n",
       "│         ┆ 份      ┆ 3       ┆ 57     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 002224  ┆ 三 力   ┆ 2023052 ┆ 09:58: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 三 力  │\n",
       "│         ┆ 士      ┆ 3       ┆ 07     ┆   ┆        ┆        ┆        ┆ 士证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 799998  ┆ 指定撤  ┆ 2023052 ┆ 15:00: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 指定撤 │\n",
       "│         ┆ 销      ┆ 2       ┆ 00     ┆   ┆        ┆        ┆        ┆ 销撤消 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 指定   │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 145,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pl.concat(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "id": "c41a34a2-2b98-4553-baa0-5cb8f5a225d0",
   "metadata": {},
   "outputs": [],
   "source": [
    "df= pl.concat(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 154,
   "id": "e0d26981-9382-4d7a-ba65-87c949974ecd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (30, 15)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>券商</th></tr><tr><td>str</td><td>str</td><td>str</td><td>str</td><td>i64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>i64</td><td>f64</td><td>i64</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>&quot;20230529&quot;</td><td>&quot;&quot;</td><td>0</td><td>0.0</td><td>600.0</td><td>600.0</td><td>&quot;卖&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;建新股份,深圳现金红利&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;131810&quot;</td><td>&quot;Ｒ-001&quot;</td><td>&quot;20230524&quot;</td><td>&quot;&quot;</td><td>1500</td><td>100.005</td><td>150007.66</td><td>150007.66</td><td>&quot;买&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;Ｒ-001,拆出购回&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;799999&quot;</td><td>&quot;指定登记&quot;</td><td>&quot;20230524&quot;</td><td>&quot;15:00:00&quot;</td><td>0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;指&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;指定登记指定交易&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;600626&quot;</td><td>&quot;申达股份&quot;</td><td>&quot;20230524&quot;</td><td>&quot;10:06:14&quot;</td><td>14800</td><td>3.37</td><td>49876.0</td><td>-49881.48</td><td>&quot;买&quot;</td><td>4.99</td><td>0</td><td>0.49</td><td>0</td><td>&quot;申达股份证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;600178&quot;</td><td>&quot;东安动力&quot;</td><td>&quot;20230524&quot;</td><td>&quot;09:59:17&quot;</td><td>16400</td><td>6.07</td><td>99548.0</td><td>-99558.97</td><td>&quot;买&quot;</td><td>9.95</td><td>0</td><td>1.02</td><td>0</td><td>&quot;东安动力证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;603002&quot;</td><td>&quot;宏昌电子&quot;</td><td>&quot;20230524&quot;</td><td>&quot;09:54:48&quot;</td><td>9800</td><td>5.06</td><td>49588.0</td><td>-49593.46</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.5</td><td>0</td><td>&quot;宏昌电子证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;131810&quot;</td><td>&quot;Ｒ-001&quot;</td><td>&quot;20230523&quot;</td><td>&quot;10:05:49&quot;</td><td>1500</td><td>1.865</td><td>150000.0</td><td>-150001.5</td><td>&quot;卖&quot;</td><td>1.5</td><td>0</td><td>0.0</td><td>0</td><td>&quot;到期日[20230524]，利息[7.66]，金额[1500…</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>&quot;20230523&quot;</td><td>&quot;10:01:57&quot;</td><td>10000</td><td>5.0</td><td>50000.0</td><td>-50005.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;建新股份证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;002224&quot;</td><td>&quot;三 力 士&quot;</td><td>&quot;20230523&quot;</td><td>&quot;09:58:07&quot;</td><td>10800</td><td>4.59</td><td>49572.0</td><td>-49576.96</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.0</td><td>0</td><td>&quot;三 力 士证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;799998&quot;</td><td>&quot;指定撤销&quot;</td><td>&quot;20230522&quot;</td><td>&quot;15:00:00&quot;</td><td>0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;撤&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;指定撤销撤消指定&quot;</td><td>&quot;海通普通&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (30, 15)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 证券代  ┆ 证券名  ┆ 成交日  ┆ 成交时 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 券商   │\n",
       "│ 码      ┆ 称      ┆ 期      ┆ 间     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ f64    ┆ i64    ┆ str    ┆ str    │\n",
       "│ str     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 300107  ┆ 建新股  ┆ 2023052 ┆        ┆ … ┆ 0.0    ┆ 0      ┆ 建新股 ┆ 海通普 │\n",
       "│         ┆ 份      ┆ 9       ┆        ┆   ┆        ┆        ┆ 份,深  ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 圳现金 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 红利   ┆        │\n",
       "│ 131810  ┆ Ｒ-001  ┆ 2023052 ┆        ┆ … ┆ 0.0    ┆ 0      ┆ Ｒ-001 ┆ 海通普 │\n",
       "│         ┆         ┆ 4       ┆        ┆   ┆        ┆        ┆ ,拆出  ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 购回   ┆        │\n",
       "│ 799999  ┆ 指定登  ┆ 2023052 ┆ 15:00: ┆ … ┆ 0.0    ┆ 0      ┆ 指定登 ┆ 海通普 │\n",
       "│         ┆ 记      ┆ 4       ┆ 00     ┆   ┆        ┆        ┆ 记指定 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 交易   ┆        │\n",
       "│ 600626  ┆ 申达股  ┆ 2023052 ┆ 10:06: ┆ … ┆ 0.49   ┆ 0      ┆ 申达股 ┆ 海通普 │\n",
       "│         ┆ 份      ┆ 4       ┆ 14     ┆   ┆        ┆        ┆ 份证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 600178  ┆ 东安动  ┆ 2023052 ┆ 09:59: ┆ … ┆ 1.02   ┆ 0      ┆ 东安动 ┆ 海通普 │\n",
       "│         ┆ 力      ┆ 4       ┆ 17     ┆   ┆        ┆        ┆ 力证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 603002  ┆ 宏昌电  ┆ 2023052 ┆ 09:54: ┆ … ┆ 0.5    ┆ 0      ┆ 宏昌电 ┆ 海通普 │\n",
       "│         ┆ 子      ┆ 4       ┆ 48     ┆   ┆        ┆        ┆ 子证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 131810  ┆ Ｒ-001  ┆ 2023052 ┆ 10:05: ┆ … ┆ 0.0    ┆ 0      ┆ 到期日 ┆ 海通普 │\n",
       "│         ┆         ┆ 3       ┆ 49     ┆   ┆        ┆        ┆ [20230 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 524]， ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 利息[7 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ .66]， ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 金额[1 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 500…   ┆        │\n",
       "│ 300107  ┆ 建新股  ┆ 2023052 ┆ 10:01: ┆ … ┆ 0.0    ┆ 0      ┆ 建新股 ┆ 海通普 │\n",
       "│         ┆ 份      ┆ 3       ┆ 57     ┆   ┆        ┆        ┆ 份证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 002224  ┆ 三 力   ┆ 2023052 ┆ 09:58: ┆ … ┆ 0.0    ┆ 0      ┆ 三 力  ┆ 海通普 │\n",
       "│         ┆ 士      ┆ 3       ┆ 07     ┆   ┆        ┆        ┆ 士证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 799998  ┆ 指定撤  ┆ 2023052 ┆ 15:00: ┆ … ┆ 0.0    ┆ 0      ┆ 指定撤 ┆ 海通普 │\n",
       "│         ┆ 销      ┆ 2       ┆ 00     ┆   ┆        ┆        ┆ 销撤消 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 指定   ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 154,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = [read_df_海通普通(p) for p in Path(\"stock_trades/\").glob(\"*-海通普通.xlsx\")]\n",
    "df= pl.concat(df)\n",
    "d2 = df.with_columns(\n",
    "    券商=pl.lit(\"海通普通\"),\n",
    ")\n",
    "d2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 151,
   "id": "736205e2-7661-4a05-a5f2-16d6f5cc07c0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (40, 15)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>券商</th></tr><tr><td>str</td><td>str</td><td>str</td><td>str</td><td>i64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>i64</td><td>f64</td><td>i64</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>&quot;20230529&quot;</td><td>&quot;&quot;</td><td>0</td><td>0.0</td><td>600.0</td><td>600.0</td><td>&quot;卖&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;建新股份,深圳现金红利&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;131810&quot;</td><td>&quot;Ｒ-001&quot;</td><td>&quot;20230524&quot;</td><td>&quot;&quot;</td><td>1500</td><td>100.005</td><td>150007.66</td><td>150007.66</td><td>&quot;买&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;Ｒ-001,拆出购回&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;799999&quot;</td><td>&quot;指定登记&quot;</td><td>&quot;20230524&quot;</td><td>&quot;15:00:00&quot;</td><td>0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;指&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;指定登记指定交易&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;600626&quot;</td><td>&quot;申达股份&quot;</td><td>&quot;20230524&quot;</td><td>&quot;10:06:14&quot;</td><td>14800</td><td>3.37</td><td>49876.0</td><td>-49881.48</td><td>&quot;买&quot;</td><td>4.99</td><td>0</td><td>0.49</td><td>0</td><td>&quot;申达股份证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;600178&quot;</td><td>&quot;东安动力&quot;</td><td>&quot;20230524&quot;</td><td>&quot;09:59:17&quot;</td><td>16400</td><td>6.07</td><td>99548.0</td><td>-99558.97</td><td>&quot;买&quot;</td><td>9.95</td><td>0</td><td>1.02</td><td>0</td><td>&quot;东安动力证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;603002&quot;</td><td>&quot;宏昌电子&quot;</td><td>&quot;20230524&quot;</td><td>&quot;09:54:48&quot;</td><td>9800</td><td>5.06</td><td>49588.0</td><td>-49593.46</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.5</td><td>0</td><td>&quot;宏昌电子证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;131810&quot;</td><td>&quot;Ｒ-001&quot;</td><td>&quot;20230523&quot;</td><td>&quot;10:05:49&quot;</td><td>1500</td><td>1.865</td><td>150000.0</td><td>-150001.5</td><td>&quot;卖&quot;</td><td>1.5</td><td>0</td><td>0.0</td><td>0</td><td>&quot;到期日[20230524]，利息[7.66]，金额[1500…</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>&quot;20230523&quot;</td><td>&quot;10:01:57&quot;</td><td>10000</td><td>5.0</td><td>50000.0</td><td>-50005.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;建新股份证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;002224&quot;</td><td>&quot;三 力 士&quot;</td><td>&quot;20230523&quot;</td><td>&quot;09:58:07&quot;</td><td>10800</td><td>4.59</td><td>49572.0</td><td>-49576.96</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.0</td><td>0</td><td>&quot;三 力 士证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;799998&quot;</td><td>&quot;指定撤销&quot;</td><td>&quot;20230522&quot;</td><td>&quot;15:00:00&quot;</td><td>0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;撤&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;指定撤销撤消指定&quot;</td><td>&quot;海通两融&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (40, 15)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 证券代  ┆ 证券名  ┆ 成交日  ┆ 成交时 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 券商   │\n",
       "│ 码      ┆ 称      ┆ 期      ┆ 间     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ f64    ┆ i64    ┆ str    ┆ str    │\n",
       "│ str     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 300107  ┆ 建新股  ┆ 2023052 ┆        ┆ … ┆ 0.0    ┆ 0      ┆ 建新股 ┆ 海通两 │\n",
       "│         ┆ 份      ┆ 9       ┆        ┆   ┆        ┆        ┆ 份,深  ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 圳现金 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 红利   ┆        │\n",
       "│ 131810  ┆ Ｒ-001  ┆ 2023052 ┆        ┆ … ┆ 0.0    ┆ 0      ┆ Ｒ-001 ┆ 海通两 │\n",
       "│         ┆         ┆ 4       ┆        ┆   ┆        ┆        ┆ ,拆出  ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 购回   ┆        │\n",
       "│ 799999  ┆ 指定登  ┆ 2023052 ┆ 15:00: ┆ … ┆ 0.0    ┆ 0      ┆ 指定登 ┆ 海通两 │\n",
       "│         ┆ 记      ┆ 4       ┆ 00     ┆   ┆        ┆        ┆ 记指定 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 交易   ┆        │\n",
       "│ 600626  ┆ 申达股  ┆ 2023052 ┆ 10:06: ┆ … ┆ 0.49   ┆ 0      ┆ 申达股 ┆ 海通两 │\n",
       "│         ┆ 份      ┆ 4       ┆ 14     ┆   ┆        ┆        ┆ 份证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 600178  ┆ 东安动  ┆ 2023052 ┆ 09:59: ┆ … ┆ 1.02   ┆ 0      ┆ 东安动 ┆ 海通两 │\n",
       "│         ┆ 力      ┆ 4       ┆ 17     ┆   ┆        ┆        ┆ 力证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 603002  ┆ 宏昌电  ┆ 2023052 ┆ 09:54: ┆ … ┆ 0.5    ┆ 0      ┆ 宏昌电 ┆ 海通两 │\n",
       "│         ┆ 子      ┆ 4       ┆ 48     ┆   ┆        ┆        ┆ 子证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 131810  ┆ Ｒ-001  ┆ 2023052 ┆ 10:05: ┆ … ┆ 0.0    ┆ 0      ┆ 到期日 ┆ 海通两 │\n",
       "│         ┆         ┆ 3       ┆ 49     ┆   ┆        ┆        ┆ [20230 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 524]， ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 利息[7 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ .66]， ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 金额[1 ┆        │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 500…   ┆        │\n",
       "│ 300107  ┆ 建新股  ┆ 2023052 ┆ 10:01: ┆ … ┆ 0.0    ┆ 0      ┆ 建新股 ┆ 海通两 │\n",
       "│         ┆ 份      ┆ 3       ┆ 57     ┆   ┆        ┆        ┆ 份证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 002224  ┆ 三 力   ┆ 2023052 ┆ 09:58: ┆ … ┆ 0.0    ┆ 0      ┆ 三 力  ┆ 海通两 │\n",
       "│         ┆ 士      ┆ 3       ┆ 07     ┆   ┆        ┆        ┆ 士证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 799998  ┆ 指定撤  ┆ 2023052 ┆ 15:00: ┆ … ┆ 0.0    ┆ 0      ┆ 指定撤 ┆ 海通两 │\n",
       "│         ┆ 销      ┆ 2       ┆ 00     ┆   ┆        ┆        ┆ 销撤消 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 指定   ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 151,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = [read_df_海通普通(p) for p in Path(\"stock_trades/\").glob(\"*-海通两融.xlsx\")]\n",
    "df= pl.concat(df)\n",
    "d3 = df.with_columns(\n",
    "    券商=pl.lit(\"海通两融\"),\n",
    ")\n",
    "d3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 162,
   "id": "9628079b-3c20-4cff-9a01-c8a600dec684",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (31, 14)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th></tr><tr><td>str</td><td>str</td><td>date</td><td>time</td><td>i64</td><td>f64</td><td>i64</td><td>f64</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>i64</td><td>str</td></tr></thead><tbody><tr><td>&quot;002136&quot;</td><td>&quot;安 纳 达&quot;</td><td>2023-06-30</td><td>10:12:58</td><td>4400</td><td>11.32</td><td>49808</td><td>-49812.98</td><td>&quot;买&quot;</td><td>4.98</td><td>0.0</td><td>0.0</td><td>0</td><td>&quot;安 纳 达证券买入&quot;</td></tr><tr><td>&quot;002492&quot;</td><td>&quot;恒基达鑫&quot;</td><td>2023-06-30</td><td>10:11:42</td><td>8700</td><td>5.74</td><td>49938</td><td>-49942.99</td><td>&quot;买&quot;</td><td>4.99</td><td>0.0</td><td>0.0</td><td>0</td><td>&quot;恒基达鑫证券买入&quot;</td></tr><tr><td>&quot;002616&quot;</td><td>&quot;长青集团&quot;</td><td>2023-06-30</td><td>10:02:56</td><td>10100</td><td>5.18</td><td>52318</td><td>52260.37</td><td>&quot;卖&quot;</td><td>5.23</td><td>52.4</td><td>0.0</td><td>0</td><td>&quot;长青集团证券卖出&quot;</td></tr><tr><td>&quot;002702&quot;</td><td>&quot;海欣食品&quot;</td><td>2023-06-30</td><td>10:06:15</td><td>9300</td><td>5.19</td><td>48267</td><td>48213.89</td><td>&quot;卖&quot;</td><td>4.83</td><td>48.28</td><td>0.0</td><td>0</td><td>&quot;海欣食品证券卖出&quot;</td></tr><tr><td>&quot;300242&quot;</td><td>&quot;佳云科技&quot;</td><td>2023-06-30</td><td>10:05:38</td><td>13200</td><td>3.4</td><td>44880</td><td>44830.63</td><td>&quot;卖&quot;</td><td>4.49</td><td>44.88</td><td>0.0</td><td>0</td><td>&quot;佳云科技证券卖出&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;002661&quot;</td><td>&quot;克明食品&quot;</td><td>2023-06-12</td><td>13:27:56</td><td>4400</td><td>11.29</td><td>49676</td><td>-49680.97</td><td>&quot;买&quot;</td><td>4.97</td><td>0.0</td><td>0.0</td><td>0</td><td>&quot;克明食品证券买入&quot;</td></tr><tr><td>&quot;600097&quot;</td><td>&quot;开创国际&quot;</td><td>2023-06-12</td><td>13:35:20</td><td>5200</td><td>9.596</td><td>49899</td><td>-49904.51</td><td>&quot;买&quot;</td><td>4.99</td><td>0.0</td><td>0.52</td><td>0</td><td>&quot;开创国际证券买入&quot;</td></tr><tr><td>&quot;600843&quot;</td><td>&quot;上工申贝&quot;</td><td>2023-06-12</td><td>13:32:09</td><td>9200</td><td>5.427</td><td>49931</td><td>-49936.51</td><td>&quot;买&quot;</td><td>4.99</td><td>0.0</td><td>0.52</td><td>0</td><td>&quot;上工申贝证券买入&quot;</td></tr><tr><td>&quot;605196&quot;</td><td>&quot;华通线缆&quot;</td><td>2023-06-12</td><td>13:29:37</td><td>7200</td><td>6.92</td><td>49824</td><td>-49829.48</td><td>&quot;买&quot;</td><td>4.98</td><td>0.0</td><td>0.5</td><td>0</td><td>&quot;华通线缆证券买入&quot;</td></tr><tr><td>&quot;600626&quot;</td><td>&quot;申达股份&quot;</td><td>2023-06-12</td><td>13:24:36</td><td>14800</td><td>3.64</td><td>53872</td><td>53812.2</td><td>&quot;卖&quot;</td><td>5.39</td><td>53.87</td><td>0.54</td><td>0</td><td>&quot;申达股份证券卖出&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (31, 14)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 证券代  ┆ 证券名  ┆ 成交日  ┆ 成交时 ┆ … ┆ 印花税 ┆ 过户费 ┆ 其他费 ┆ 备注   │\n",
       "│ 码      ┆ 称      ┆ 期      ┆ 间     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ f64    ┆ f64    ┆ i64    ┆ str    │\n",
       "│ str     ┆ str     ┆ date    ┆ time   ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 002136  ┆ 安 纳   ┆ 2023-06 ┆ 10:12: ┆ … ┆ 0.0    ┆ 0.0    ┆ 0      ┆ 安 纳  │\n",
       "│         ┆ 达      ┆ -30     ┆ 58     ┆   ┆        ┆        ┆        ┆ 达证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 002492  ┆ 恒基达  ┆ 2023-06 ┆ 10:11: ┆ … ┆ 0.0    ┆ 0.0    ┆ 0      ┆ 恒基达 │\n",
       "│         ┆ 鑫      ┆ -30     ┆ 42     ┆   ┆        ┆        ┆        ┆ 鑫证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 002616  ┆ 长青集  ┆ 2023-06 ┆ 10:02: ┆ … ┆ 52.4   ┆ 0.0    ┆ 0      ┆ 长青集 │\n",
       "│         ┆ 团      ┆ -30     ┆ 56     ┆   ┆        ┆        ┆        ┆ 团证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 卖出   │\n",
       "│ 002702  ┆ 海欣食  ┆ 2023-06 ┆ 10:06: ┆ … ┆ 48.28  ┆ 0.0    ┆ 0      ┆ 海欣食 │\n",
       "│         ┆ 品      ┆ -30     ┆ 15     ┆   ┆        ┆        ┆        ┆ 品证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 卖出   │\n",
       "│ 300242  ┆ 佳云科  ┆ 2023-06 ┆ 10:05: ┆ … ┆ 44.88  ┆ 0.0    ┆ 0      ┆ 佳云科 │\n",
       "│         ┆ 技      ┆ -30     ┆ 38     ┆   ┆        ┆        ┆        ┆ 技证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 卖出   │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 002661  ┆ 克明食  ┆ 2023-06 ┆ 13:27: ┆ … ┆ 0.0    ┆ 0.0    ┆ 0      ┆ 克明食 │\n",
       "│         ┆ 品      ┆ -12     ┆ 56     ┆   ┆        ┆        ┆        ┆ 品证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 600097  ┆ 开创国  ┆ 2023-06 ┆ 13:35: ┆ … ┆ 0.0    ┆ 0.52   ┆ 0      ┆ 开创国 │\n",
       "│         ┆ 际      ┆ -12     ┆ 20     ┆   ┆        ┆        ┆        ┆ 际证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 600843  ┆ 上工申  ┆ 2023-06 ┆ 13:32: ┆ … ┆ 0.0    ┆ 0.52   ┆ 0      ┆ 上工申 │\n",
       "│         ┆ 贝      ┆ -12     ┆ 09     ┆   ┆        ┆        ┆        ┆ 贝证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 605196  ┆ 华通线  ┆ 2023-06 ┆ 13:29: ┆ … ┆ 0.0    ┆ 0.5    ┆ 0      ┆ 华通线 │\n",
       "│         ┆ 缆      ┆ -12     ┆ 37     ┆   ┆        ┆        ┆        ┆ 缆证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 600626  ┆ 申达股  ┆ 2023-06 ┆ 13:24: ┆ … ┆ 53.87  ┆ 0.54   ┆ 0      ┆ 申达股 │\n",
       "│         ┆ 份      ┆ -12     ┆ 36     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 卖出   │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 162,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def read_df_海通普通(f: str | Path) -> pl.DataFrame:\n",
    "    df = pl.read_excel(\n",
    "         f,\n",
    "         schema_overrides={\n",
    "             \"成交日期\": pl.String,\n",
    "             \"成交时间\":pl. String,\n",
    "         },\n",
    "    )\n",
    "    df = (\n",
    "       df.filter(\n",
    "           (pl.col(\"成交时间\")!=\"\")\n",
    "           &(pl.col(\"操作\").is_in([\"买\",\"卖\"]))\n",
    "           &(~pl.col(\"证券代码\").str.starts_with(\"204\"))\n",
    "           &(~pl.col(\"证券代码\").str.starts_with(\"1318\"))\n",
    "        ).with_columns(\n",
    "            pl.col(\"成交日期\").str.to_date(\"%Y%m%d\"),\n",
    "            pl.col(\"成交时间\").str.to_time(\"%H:%M:%S\"),\n",
    "        )\n",
    "   )\n",
    "    return df\n",
    "read_df_海通普通(\"stock_trades/202306-海通普通.xlsx\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "id": "dc93f2ec-0f83-4384-bb46-413192f2300d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17, 14)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th></tr><tr><td>str</td><td>str</td><td>date</td><td>time</td><td>i64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>i64</td><td>str</td></tr></thead><tbody><tr><td>&quot;300642&quot;</td><td>&quot;透景生命&quot;</td><td>2023-07-24</td><td>09:49:52</td><td>2500</td><td>19.69</td><td>49225.0</td><td>-49229.92</td><td>&quot;买&quot;</td><td>4.92</td><td>0.0</td><td>0.0</td><td>0</td><td>&quot;透景生命证券买入&quot;</td></tr><tr><td>&quot;000599&quot;</td><td>&quot;青岛双星&quot;</td><td>2023-07-24</td><td>09:37:23</td><td>11900</td><td>4.46</td><td>53074.0</td><td>53015.62</td><td>&quot;卖&quot;</td><td>5.31</td><td>53.07</td><td>0.0</td><td>0</td><td>&quot;青岛双星证券卖出&quot;</td></tr><tr><td>&quot;002225&quot;</td><td>&quot;濮耐股份&quot;</td><td>2023-07-24</td><td>09:42:11</td><td>13200</td><td>3.8</td><td>50160.0</td><td>-50165.02</td><td>&quot;买&quot;</td><td>5.02</td><td>0.0</td><td>0.0</td><td>0</td><td>&quot;濮耐股份证券买入&quot;</td></tr><tr><td>&quot;000823&quot;</td><td>&quot;超声电子&quot;</td><td>2023-07-24</td><td>09:52:23</td><td>5400</td><td>9.38</td><td>50652.0</td><td>-50657.07</td><td>&quot;买&quot;</td><td>5.07</td><td>0.0</td><td>0.0</td><td>0</td><td>&quot;超声电子证券买入&quot;</td></tr><tr><td>&quot;600735&quot;</td><td>&quot;新华锦&quot;</td><td>2023-07-24</td><td>09:48:27</td><td>8200</td><td>6.07</td><td>49774.0</td><td>-49779.48</td><td>&quot;买&quot;</td><td>4.98</td><td>0.0</td><td>0.5</td><td>0</td><td>&quot;新华锦证券买入&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;605196&quot;</td><td>&quot;华通线缆&quot;</td><td>2023-07-17</td><td>10:03:09</td><td>7200</td><td>7.81</td><td>56232.0</td><td>56169.59</td><td>&quot;卖&quot;</td><td>5.62</td><td>56.23</td><td>0.56</td><td>0</td><td>&quot;华通线缆证券卖出&quot;</td></tr><tr><td>&quot;002842&quot;</td><td>&quot;翔鹭钨业&quot;</td><td>2023-07-11</td><td>10:04:39</td><td>5900</td><td>8.68</td><td>51212.0</td><td>51155.66</td><td>&quot;卖&quot;</td><td>5.12</td><td>51.22</td><td>0.0</td><td>0</td><td>&quot;翔鹭钨业证券卖出&quot;</td></tr><tr><td>&quot;002331&quot;</td><td>&quot;皖通科技&quot;</td><td>2023-07-11</td><td>10:03:52</td><td>6900</td><td>7.33</td><td>50577.0</td><td>50521.36</td><td>&quot;卖&quot;</td><td>5.06</td><td>50.58</td><td>0.0</td><td>0</td><td>&quot;皖通科技证券卖出&quot;</td></tr><tr><td>&quot;600300&quot;</td><td>&quot;维维股份&quot;</td><td>2023-07-11</td><td>10:13:04</td><td>16400</td><td>3.05</td><td>50020.0</td><td>-50025.5</td><td>&quot;买&quot;</td><td>5.0</td><td>0.0</td><td>0.5</td><td>0</td><td>&quot;维维股份证券买入&quot;</td></tr><tr><td>&quot;600287&quot;</td><td>&quot;江苏舜天&quot;</td><td>2023-07-11</td><td>10:08:50</td><td>9900</td><td>5.06</td><td>50094.0</td><td>-50099.51</td><td>&quot;买&quot;</td><td>5.01</td><td>0.0</td><td>0.5</td><td>0</td><td>&quot;江苏舜天证券买入&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17, 14)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 证券代  ┆ 证券名  ┆ 成交日  ┆ 成交时 ┆ … ┆ 印花税 ┆ 过户费 ┆ 其他费 ┆ 备注   │\n",
       "│ 码      ┆ 称      ┆ 期      ┆ 间     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ f64    ┆ f64    ┆ i64    ┆ str    │\n",
       "│ str     ┆ str     ┆ date    ┆ time   ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 300642  ┆ 透景生  ┆ 2023-07 ┆ 09:49: ┆ … ┆ 0.0    ┆ 0.0    ┆ 0      ┆ 透景生 │\n",
       "│         ┆ 命      ┆ -24     ┆ 52     ┆   ┆        ┆        ┆        ┆ 命证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 000599  ┆ 青岛双  ┆ 2023-07 ┆ 09:37: ┆ … ┆ 53.07  ┆ 0.0    ┆ 0      ┆ 青岛双 │\n",
       "│         ┆ 星      ┆ -24     ┆ 23     ┆   ┆        ┆        ┆        ┆ 星证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 卖出   │\n",
       "│ 002225  ┆ 濮耐股  ┆ 2023-07 ┆ 09:42: ┆ … ┆ 0.0    ┆ 0.0    ┆ 0      ┆ 濮耐股 │\n",
       "│         ┆ 份      ┆ -24     ┆ 11     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 000823  ┆ 超声电  ┆ 2023-07 ┆ 09:52: ┆ … ┆ 0.0    ┆ 0.0    ┆ 0      ┆ 超声电 │\n",
       "│         ┆ 子      ┆ -24     ┆ 23     ┆   ┆        ┆        ┆        ┆ 子证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 600735  ┆ 新华锦  ┆ 2023-07 ┆ 09:48: ┆ … ┆ 0.0    ┆ 0.5    ┆ 0      ┆ 新华锦 │\n",
       "│         ┆         ┆ -24     ┆ 27     ┆   ┆        ┆        ┆        ┆ 证券买 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 入     │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 605196  ┆ 华通线  ┆ 2023-07 ┆ 10:03: ┆ … ┆ 56.23  ┆ 0.56   ┆ 0      ┆ 华通线 │\n",
       "│         ┆ 缆      ┆ -17     ┆ 09     ┆   ┆        ┆        ┆        ┆ 缆证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 卖出   │\n",
       "│ 002842  ┆ 翔鹭钨  ┆ 2023-07 ┆ 10:04: ┆ … ┆ 51.22  ┆ 0.0    ┆ 0      ┆ 翔鹭钨 │\n",
       "│         ┆ 业      ┆ -11     ┆ 39     ┆   ┆        ┆        ┆        ┆ 业证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 卖出   │\n",
       "│ 002331  ┆ 皖通科  ┆ 2023-07 ┆ 10:03: ┆ … ┆ 50.58  ┆ 0.0    ┆ 0      ┆ 皖通科 │\n",
       "│         ┆ 技      ┆ -11     ┆ 52     ┆   ┆        ┆        ┆        ┆ 技证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 卖出   │\n",
       "│ 600300  ┆ 维维股  ┆ 2023-07 ┆ 10:13: ┆ … ┆ 0.0    ┆ 0.5    ┆ 0      ┆ 维维股 │\n",
       "│         ┆ 份      ┆ -11     ┆ 04     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 600287  ┆ 江苏舜  ┆ 2023-07 ┆ 10:08: ┆ … ┆ 0.0    ┆ 0.5    ┆ 0      ┆ 江苏舜 │\n",
       "│         ┆ 天      ┆ -11     ┆ 50     ┆   ┆        ┆        ┆        ┆ 天证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 163,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def read_df_海通普通(f: str | Path) -> pl.DataFrame:\n",
    "    df = pl.read_excel(\n",
    "         f,\n",
    "         schema_overrides={\n",
    "             \"成交日期\": pl.String,\n",
    "             \"成交时间\":pl. String,\n",
    "         },\n",
    "    )\n",
    "    df = (\n",
    "       df.filter(\n",
    "           (pl.col(\"成交时间\")!=\"\")\n",
    "           &(pl.col(\"操作\").is_in([\"买\",\"卖\"]))\n",
    "           &(~pl.col(\"证券代码\").str.starts_with(\"204\"))\n",
    "           &(~pl.col(\"证券代码\").str.starts_with(\"1318\"))\n",
    "        ).with_columns(\n",
    "            pl.col(\"成交日期\").str.to_date(\"%Y%m%d\"),\n",
    "            pl.col(\"成交时间\").str.to_time(\"%H:%M:%S\"),\n",
    "        )\n",
    "   )\n",
    "    return df\n",
    "read_df_海通普通(\"stock_trades/202307-海通普通.xlsx\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 164,
   "id": "2a88680a-5141-41c0-b3b6-1d0b48b120b3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (30, 14)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th></tr><tr><td>str</td><td>str</td><td>str</td><td>str</td><td>i64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>i64</td><td>f64</td><td>i64</td><td>str</td></tr></thead><tbody><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>&quot;20230529&quot;</td><td>&quot;&quot;</td><td>0</td><td>0.0</td><td>600.0</td><td>600.0</td><td>&quot;卖&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;建新股份,深圳现金红利&quot;</td></tr><tr><td>&quot;131810&quot;</td><td>&quot;Ｒ-001&quot;</td><td>&quot;20230524&quot;</td><td>&quot;&quot;</td><td>1500</td><td>100.005</td><td>150007.66</td><td>150007.66</td><td>&quot;买&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;Ｒ-001,拆出购回&quot;</td></tr><tr><td>&quot;799999&quot;</td><td>&quot;指定登记&quot;</td><td>&quot;20230524&quot;</td><td>&quot;15:00:00&quot;</td><td>0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;指&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;指定登记指定交易&quot;</td></tr><tr><td>&quot;600626&quot;</td><td>&quot;申达股份&quot;</td><td>&quot;20230524&quot;</td><td>&quot;10:06:14&quot;</td><td>14800</td><td>3.37</td><td>49876.0</td><td>-49881.48</td><td>&quot;买&quot;</td><td>4.99</td><td>0</td><td>0.49</td><td>0</td><td>&quot;申达股份证券买入&quot;</td></tr><tr><td>&quot;600178&quot;</td><td>&quot;东安动力&quot;</td><td>&quot;20230524&quot;</td><td>&quot;09:59:17&quot;</td><td>16400</td><td>6.07</td><td>99548.0</td><td>-99558.97</td><td>&quot;买&quot;</td><td>9.95</td><td>0</td><td>1.02</td><td>0</td><td>&quot;东安动力证券买入&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;603002&quot;</td><td>&quot;宏昌电子&quot;</td><td>&quot;20230524&quot;</td><td>&quot;09:54:48&quot;</td><td>9800</td><td>5.06</td><td>49588.0</td><td>-49593.46</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.5</td><td>0</td><td>&quot;宏昌电子证券买入&quot;</td></tr><tr><td>&quot;131810&quot;</td><td>&quot;Ｒ-001&quot;</td><td>&quot;20230523&quot;</td><td>&quot;10:05:49&quot;</td><td>1500</td><td>1.865</td><td>150000.0</td><td>-150001.5</td><td>&quot;卖&quot;</td><td>1.5</td><td>0</td><td>0.0</td><td>0</td><td>&quot;到期日[20230524]，利息[7.66]，金额[1500…</td></tr><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>&quot;20230523&quot;</td><td>&quot;10:01:57&quot;</td><td>10000</td><td>5.0</td><td>50000.0</td><td>-50005.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;建新股份证券买入&quot;</td></tr><tr><td>&quot;002224&quot;</td><td>&quot;三 力 士&quot;</td><td>&quot;20230523&quot;</td><td>&quot;09:58:07&quot;</td><td>10800</td><td>4.59</td><td>49572.0</td><td>-49576.96</td><td>&quot;买&quot;</td><td>4.96</td><td>0</td><td>0.0</td><td>0</td><td>&quot;三 力 士证券买入&quot;</td></tr><tr><td>&quot;799998&quot;</td><td>&quot;指定撤销&quot;</td><td>&quot;20230522&quot;</td><td>&quot;15:00:00&quot;</td><td>0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;撤&quot;</td><td>0.0</td><td>0</td><td>0.0</td><td>0</td><td>&quot;指定撤销撤消指定&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (30, 14)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 证券代  ┆ 证券名  ┆ 成交日  ┆ 成交时 ┆ … ┆ 印花税 ┆ 过户费 ┆ 其他费 ┆ 备注   │\n",
       "│ 码      ┆ 称      ┆ 期      ┆ 间     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ i64    ┆ f64    ┆ i64    ┆ str    │\n",
       "│ str     ┆ str     ┆ str     ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 300107  ┆ 建新股  ┆ 2023052 ┆        ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 建新股 │\n",
       "│         ┆ 份      ┆ 9       ┆        ┆   ┆        ┆        ┆        ┆ 份,深  │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 圳现金 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 红利   │\n",
       "│ 131810  ┆ Ｒ-001  ┆ 2023052 ┆        ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ Ｒ-001 │\n",
       "│         ┆         ┆ 4       ┆        ┆   ┆        ┆        ┆        ┆ ,拆出  │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 购回   │\n",
       "│ 799999  ┆ 指定登  ┆ 2023052 ┆ 15:00: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 指定登 │\n",
       "│         ┆ 记      ┆ 4       ┆ 00     ┆   ┆        ┆        ┆        ┆ 记指定 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 交易   │\n",
       "│ 600626  ┆ 申达股  ┆ 2023052 ┆ 10:06: ┆ … ┆ 0      ┆ 0.49   ┆ 0      ┆ 申达股 │\n",
       "│         ┆ 份      ┆ 4       ┆ 14     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 600178  ┆ 东安动  ┆ 2023052 ┆ 09:59: ┆ … ┆ 0      ┆ 1.02   ┆ 0      ┆ 东安动 │\n",
       "│         ┆ 力      ┆ 4       ┆ 17     ┆   ┆        ┆        ┆        ┆ 力证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 603002  ┆ 宏昌电  ┆ 2023052 ┆ 09:54: ┆ … ┆ 0      ┆ 0.5    ┆ 0      ┆ 宏昌电 │\n",
       "│         ┆ 子      ┆ 4       ┆ 48     ┆   ┆        ┆        ┆        ┆ 子证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 131810  ┆ Ｒ-001  ┆ 2023052 ┆ 10:05: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 到期日 │\n",
       "│         ┆         ┆ 3       ┆ 49     ┆   ┆        ┆        ┆        ┆ [20230 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 524]， │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 利息[7 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ .66]， │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 金额[1 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 500…   │\n",
       "│ 300107  ┆ 建新股  ┆ 2023052 ┆ 10:01: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 建新股 │\n",
       "│         ┆ 份      ┆ 3       ┆ 57     ┆   ┆        ┆        ┆        ┆ 份证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 002224  ┆ 三 力   ┆ 2023052 ┆ 09:58: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 三 力  │\n",
       "│         ┆ 士      ┆ 3       ┆ 07     ┆   ┆        ┆        ┆        ┆ 士证券 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 买入   │\n",
       "│ 799998  ┆ 指定撤  ┆ 2023052 ┆ 15:00: ┆ … ┆ 0      ┆ 0.0    ┆ 0      ┆ 指定撤 │\n",
       "│         ┆ 销      ┆ 2       ┆ 00     ┆   ┆        ┆        ┆        ┆ 销撤消 │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆        ┆ 指定   │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 164,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 170,
   "id": "3b389734-f84b-40f8-9d60-bba6d19261f9",
   "metadata": {},
   "outputs": [],
   "source": [
    "def read_df_海通普通(f: str | Path) -> pl.DataFrame:\n",
    "    df = pl.read_excel(\n",
    "         f,\n",
    "         schema_overrides={\n",
    "             \"成交日期\": pl.String,\n",
    "             \"成交时间\":pl.String,\n",
    "             \"成交数量\":pl.Float64,\n",
    "             \"成交金额\":pl.Float64,\n",
    "             \"印花税\":pl.Float64,\n",
    "             \"其他费\":pl.Float64,\n",
    "         },\n",
    "    )\n",
    "    df = (\n",
    "       df.filter(\n",
    "           (pl.col(\"成交时间\")!=\"\")\n",
    "           &(pl.col(\"操作\").is_in([\"买\",\"卖\"]))\n",
    "           &(~pl.col(\"证券代码\").str.starts_with(\"204\"))\n",
    "           &(~pl.col(\"证券代码\").str.starts_with(\"1318\"))\n",
    "        ).with_columns(\n",
    "            pl.col(\"成交日期\").str.to_date(\"%Y%m%d\"),\n",
    "            pl.col(\"成交时间\").str.to_time(\"%H:%M:%S\"),\n",
    "        )\n",
    "   )\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "id": "898cac8e-794c-479d-afc5-b6d80476f261",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (53, 15)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>券商</th></tr><tr><td>str</td><td>str</td><td>date</td><td>time</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;002224&quot;</td><td>&quot;三 力 士&quot;</td><td>2023-05-23</td><td>09:58:07</td><td>10800.0</td><td>4.59</td><td>49572.0</td><td>-49576.96</td><td>&quot;买&quot;</td><td>4.96</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;三 力 士证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>2023-05-23</td><td>10:01:57</td><td>10000.0</td><td>5.0</td><td>50000.0</td><td>-50005.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;建新股份证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;603002&quot;</td><td>&quot;宏昌电子&quot;</td><td>2023-05-24</td><td>09:54:48</td><td>9800.0</td><td>5.06</td><td>49588.0</td><td>-49593.46</td><td>&quot;买&quot;</td><td>4.96</td><td>0.0</td><td>0.5</td><td>0.0</td><td>&quot;宏昌电子证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;600178&quot;</td><td>&quot;东安动力&quot;</td><td>2023-05-24</td><td>09:59:17</td><td>16400.0</td><td>6.07</td><td>99548.0</td><td>-99558.97</td><td>&quot;买&quot;</td><td>9.95</td><td>0.0</td><td>1.02</td><td>0.0</td><td>&quot;东安动力证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;600626&quot;</td><td>&quot;申达股份&quot;</td><td>2023-05-24</td><td>10:06:14</td><td>14800.0</td><td>3.37</td><td>49876.0</td><td>-49881.48</td><td>&quot;买&quot;</td><td>4.99</td><td>0.0</td><td>0.49</td><td>0.0</td><td>&quot;申达股份证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;603386&quot;</td><td>&quot;骏亚科技&quot;</td><td>2023-07-24</td><td>09:38:22</td><td>4500.0</td><td>11.32</td><td>50940.0</td><td>50883.51</td><td>&quot;卖&quot;</td><td>5.09</td><td>50.91</td><td>0.49</td><td>0.0</td><td>&quot;骏亚科技证券卖出&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;002225&quot;</td><td>&quot;濮耐股份&quot;</td><td>2023-07-24</td><td>09:42:11</td><td>13200.0</td><td>3.8</td><td>50160.0</td><td>-50165.02</td><td>&quot;买&quot;</td><td>5.02</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;濮耐股份证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;600735&quot;</td><td>&quot;新华锦&quot;</td><td>2023-07-24</td><td>09:48:27</td><td>8200.0</td><td>6.07</td><td>49774.0</td><td>-49779.48</td><td>&quot;买&quot;</td><td>4.98</td><td>0.0</td><td>0.5</td><td>0.0</td><td>&quot;新华锦证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;300642&quot;</td><td>&quot;透景生命&quot;</td><td>2023-07-24</td><td>09:49:52</td><td>2500.0</td><td>19.69</td><td>49225.0</td><td>-49229.92</td><td>&quot;买&quot;</td><td>4.92</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;透景生命证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;000823&quot;</td><td>&quot;超声电子&quot;</td><td>2023-07-24</td><td>09:52:23</td><td>5400.0</td><td>9.38</td><td>50652.0</td><td>-50657.07</td><td>&quot;买&quot;</td><td>5.07</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;超声电子证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (53, 15)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 证券代  ┆ 证券名  ┆ 成交日  ┆ 成交时 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 券商   │\n",
       "│ 码      ┆ 称      ┆ 期      ┆ 间     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ f64    ┆ f64    ┆ str    ┆ str    │\n",
       "│ str     ┆ str     ┆ date    ┆ time   ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 002224  ┆ 三 力   ┆ 2023-05 ┆ 09:58: ┆ … ┆ 0.0    ┆ 0.0    ┆ 三 力  ┆ 海通普 │\n",
       "│         ┆ 士      ┆ -23     ┆ 07     ┆   ┆        ┆        ┆ 士证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 300107  ┆ 建新股  ┆ 2023-05 ┆ 10:01: ┆ … ┆ 0.0    ┆ 0.0    ┆ 建新股 ┆ 海通普 │\n",
       "│         ┆ 份      ┆ -23     ┆ 57     ┆   ┆        ┆        ┆ 份证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 603002  ┆ 宏昌电  ┆ 2023-05 ┆ 09:54: ┆ … ┆ 0.5    ┆ 0.0    ┆ 宏昌电 ┆ 海通普 │\n",
       "│         ┆ 子      ┆ -24     ┆ 48     ┆   ┆        ┆        ┆ 子证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 600178  ┆ 东安动  ┆ 2023-05 ┆ 09:59: ┆ … ┆ 1.02   ┆ 0.0    ┆ 东安动 ┆ 海通普 │\n",
       "│         ┆ 力      ┆ -24     ┆ 17     ┆   ┆        ┆        ┆ 力证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 600626  ┆ 申达股  ┆ 2023-05 ┆ 10:06: ┆ … ┆ 0.49   ┆ 0.0    ┆ 申达股 ┆ 海通普 │\n",
       "│         ┆ 份      ┆ -24     ┆ 14     ┆   ┆        ┆        ┆ 份证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 603386  ┆ 骏亚科  ┆ 2023-07 ┆ 09:38: ┆ … ┆ 0.49   ┆ 0.0    ┆ 骏亚科 ┆ 海通普 │\n",
       "│         ┆ 技      ┆ -24     ┆ 22     ┆   ┆        ┆        ┆ 技证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 卖出   ┆        │\n",
       "│ 002225  ┆ 濮耐股  ┆ 2023-07 ┆ 09:42: ┆ … ┆ 0.0    ┆ 0.0    ┆ 濮耐股 ┆ 海通普 │\n",
       "│         ┆ 份      ┆ -24     ┆ 11     ┆   ┆        ┆        ┆ 份证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 600735  ┆ 新华锦  ┆ 2023-07 ┆ 09:48: ┆ … ┆ 0.5    ┆ 0.0    ┆ 新华锦 ┆ 海通普 │\n",
       "│         ┆         ┆ -24     ┆ 27     ┆   ┆        ┆        ┆ 证券买 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "│ 300642  ┆ 透景生  ┆ 2023-07 ┆ 09:49: ┆ … ┆ 0.0    ┆ 0.0    ┆ 透景生 ┆ 海通普 │\n",
       "│         ┆ 命      ┆ -24     ┆ 52     ┆   ┆        ┆        ┆ 命证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 000823  ┆ 超声电  ┆ 2023-07 ┆ 09:52: ┆ … ┆ 0.0    ┆ 0.0    ┆ 超声电 ┆ 海通普 │\n",
       "│         ┆ 子      ┆ -24     ┆ 23     ┆   ┆        ┆        ┆ 子证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 173,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = [read_df_海通普通(p) for p in Path(\"stock_trades/\").glob(\"*-海通普通.xlsx\")]\n",
    "df= pl.concat(df)\n",
    "d2 = df.with_columns(\n",
    "    券商=pl.lit(\"海通普通\"),\n",
    ")\n",
    "d2.sort(\"成交日期\",\"成交时间\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "id": "f9a30766-7d99-4c67-ada7-5b0cf0119d03",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (53, 15)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>券商</th></tr><tr><td>str</td><td>str</td><td>date</td><td>time</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;600638&quot;</td><td>&quot;新黄浦&quot;</td><td>2023-07-26</td><td>09:33:56</td><td>9300.0</td><td>6.526</td><td>60696.0</td><td>60628.01</td><td>&quot;卖&quot;</td><td>6.68</td><td>60.7</td><td>0.61</td><td>0.0</td><td>&quot;新黄浦证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;002492&quot;</td><td>&quot;恒基达鑫&quot;</td><td>2023-07-27</td><td>09:30:42</td><td>8700.0</td><td>6.12</td><td>53244.0</td><td>53184.91</td><td>&quot;卖&quot;</td><td>5.86</td><td>53.23</td><td>0.0</td><td>0.0</td><td>&quot;恒基达鑫证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;002136&quot;</td><td>&quot;安 纳 达&quot;</td><td>2023-07-27</td><td>09:32:52</td><td>4400.0</td><td>11.881</td><td>52277.0</td><td>52218.97</td><td>&quot;卖&quot;</td><td>5.75</td><td>52.28</td><td>0.0</td><td>0.0</td><td>&quot;安 纳 达证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;600300&quot;</td><td>&quot;维维股份&quot;</td><td>2023-08-04</td><td>09:36:55</td><td>16400.0</td><td>3.27</td><td>53628.0</td><td>53567.91</td><td>&quot;卖&quot;</td><td>5.9</td><td>53.65</td><td>0.54</td><td>0.0</td><td>&quot;维维股份证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;300241&quot;</td><td>&quot;瑞丰光电&quot;</td><td>2023-08-04</td><td>09:39:38</td><td>9700.0</td><td>5.13</td><td>49761.0</td><td>-49766.47</td><td>&quot;买&quot;</td><td>5.47</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;瑞丰光电证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;002956&quot;</td><td>&quot;西麦食品&quot;</td><td>2023-10-31</td><td>09:31:53</td><td>5000.0</td><td>14.13</td><td>70650.0</td><td>70607.91</td><td>&quot;卖&quot;</td><td>6.74</td><td>35.35</td><td>0.0</td><td>0.0</td><td>&quot;西麦食品证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;603214&quot;</td><td>&quot;爱婴室&quot;</td><td>2023-10-31</td><td>09:39:57</td><td>3100.0</td><td>15.84</td><td>49104.0</td><td>-49109.51</td><td>&quot;买&quot;</td><td>5.0</td><td>0.0</td><td>0.51</td><td>0.0</td><td>&quot;爱婴室证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;300132&quot;</td><td>&quot;青松股份&quot;</td><td>2023-10-31</td><td>09:40:55</td><td>9600.0</td><td>5.21</td><td>50016.0</td><td>-50021.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;青松股份证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;002492&quot;</td><td>&quot;恒基达鑫&quot;</td><td>2023-10-31</td><td>09:43:13</td><td>8400.0</td><td>5.91</td><td>49644.0</td><td>-49649.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;恒基达鑫证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;002111&quot;</td><td>&quot;威海广泰&quot;</td><td>2023-10-31</td><td>09:44:45</td><td>5400.0</td><td>9.24</td><td>49896.0</td><td>-49901.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;威海广泰证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (53, 15)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 证券代  ┆ 证券名  ┆ 成交日  ┆ 成交时 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 券商   │\n",
       "│ 码      ┆ 称      ┆ 期      ┆ 间     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ f64    ┆ f64    ┆ str    ┆ str    │\n",
       "│ str     ┆ str     ┆ date    ┆ time   ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 600638  ┆ 新黄浦  ┆ 2023-07 ┆ 09:33: ┆ … ┆ 0.61   ┆ 0.0    ┆ 新黄浦 ┆ 海通两 │\n",
       "│         ┆         ┆ -26     ┆ 56     ┆   ┆        ┆        ┆ 证券卖 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 出     ┆        │\n",
       "│ 002492  ┆ 恒基达  ┆ 2023-07 ┆ 09:30: ┆ … ┆ 0.0    ┆ 0.0    ┆ 恒基达 ┆ 海通两 │\n",
       "│         ┆ 鑫      ┆ -27     ┆ 42     ┆   ┆        ┆        ┆ 鑫证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 卖出   ┆        │\n",
       "│ 002136  ┆ 安 纳   ┆ 2023-07 ┆ 09:32: ┆ … ┆ 0.0    ┆ 0.0    ┆ 安 纳  ┆ 海通两 │\n",
       "│         ┆ 达      ┆ -27     ┆ 52     ┆   ┆        ┆        ┆ 达证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 卖出   ┆        │\n",
       "│ 600300  ┆ 维维股  ┆ 2023-08 ┆ 09:36: ┆ … ┆ 0.54   ┆ 0.0    ┆ 维维股 ┆ 海通两 │\n",
       "│         ┆ 份      ┆ -04     ┆ 55     ┆   ┆        ┆        ┆ 份证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 卖出   ┆        │\n",
       "│ 300241  ┆ 瑞丰光  ┆ 2023-08 ┆ 09:39: ┆ … ┆ 0.0    ┆ 0.0    ┆ 瑞丰光 ┆ 海通两 │\n",
       "│         ┆ 电      ┆ -04     ┆ 38     ┆   ┆        ┆        ┆ 电证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 002956  ┆ 西麦食  ┆ 2023-10 ┆ 09:31: ┆ … ┆ 0.0    ┆ 0.0    ┆ 西麦食 ┆ 海通两 │\n",
       "│         ┆ 品      ┆ -31     ┆ 53     ┆   ┆        ┆        ┆ 品证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 卖出   ┆        │\n",
       "│ 603214  ┆ 爱婴室  ┆ 2023-10 ┆ 09:39: ┆ … ┆ 0.51   ┆ 0.0    ┆ 爱婴室 ┆ 海通两 │\n",
       "│         ┆         ┆ -31     ┆ 57     ┆   ┆        ┆        ┆ 证券买 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 入     ┆        │\n",
       "│ 300132  ┆ 青松股  ┆ 2023-10 ┆ 09:40: ┆ … ┆ 0.0    ┆ 0.0    ┆ 青松股 ┆ 海通两 │\n",
       "│         ┆ 份      ┆ -31     ┆ 55     ┆   ┆        ┆        ┆ 份证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 002492  ┆ 恒基达  ┆ 2023-10 ┆ 09:43: ┆ … ┆ 0.0    ┆ 0.0    ┆ 恒基达 ┆ 海通两 │\n",
       "│         ┆ 鑫      ┆ -31     ┆ 13     ┆   ┆        ┆        ┆ 鑫证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 002111  ┆ 威海广  ┆ 2023-10 ┆ 09:44: ┆ … ┆ 0.0    ┆ 0.0    ┆ 威海广 ┆ 海通两 │\n",
       "│         ┆ 泰      ┆ -31     ┆ 45     ┆   ┆        ┆        ┆ 泰证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 174,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = [read_df_海通普通(p) for p in Path(\"stock_trades/\").glob(\"*-海通两融.xlsx\")]\n",
    "df= pl.concat(df)\n",
    "d3 = df.with_columns(\n",
    "    券商=pl.lit(\"海通两融\"),\n",
    ")\n",
    "d3.sort(\"成交日期\",\"成交时间\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 239,
   "id": "bfd62d69-e6af-47fa-87d7-fa336d0fa3ee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (257, 14)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th></tr><tr><td>str</td><td>date</td><td>time</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:38:10</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;嘉事堂&quot;</td><td>13.2062</td><td>10400.0</td><td>137344.0</td><td>21.98</td><td>137.35</td><td>1.38</td><td>0.0</td><td>137184.67</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:44:52</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;安泰集团&quot;</td><td>3.19</td><td>47000.0</td><td>149930.0</td><td>23.99</td><td>0.0</td><td>1.51</td><td>0.0</td><td>-149955.5</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:44:31</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;外高桥&quot;</td><td>12.6066</td><td>11900.0</td><td>150019.0</td><td>24.0</td><td>0.0</td><td>1.49</td><td>0.0</td><td>-150044.49</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:43:38</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;赣粤高速&quot;</td><td>3.69</td><td>40700.0</td><td>150183.0</td><td>24.03</td><td>0.0</td><td>1.5</td><td>0.0</td><td>-150208.53</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:42:51</td><td>&quot;600015&quot;</td><td>&quot;华夏银行&quot;</td><td>&quot;华夏银行&quot;</td><td>5.07</td><td>30000.0</td><td>152100.0</td><td>24.34</td><td>0.0</td><td>1.52</td><td>0.0</td><td>-152125.86</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;湘财&quot;</td><td>2023-06-19</td><td>10:18:46</td><td>&quot;603967&quot;</td><td>&quot;中创物流&quot;</td><td>&quot;中创物流&quot;</td><td>9.13</td><td>5000.0</td><td>45650.0</td><td>7.3</td><td>45.65</td><td>0.46</td><td>0.0</td><td>45596.59</td></tr><tr><td>&quot;湘财&quot;</td><td>2023-06-12</td><td>13:22:32</td><td>&quot;300641&quot;</td><td>&quot;正丹股份&quot;</td><td>&quot;正丹股份&quot;</td><td>5.05</td><td>9600.0</td><td>48480.0</td><td>7.76</td><td>48.48</td><td>0.48</td><td>0.0</td><td>48423.76</td></tr><tr><td>&quot;湘财&quot;</td><td>2023-06-02</td><td>10:26:35</td><td>&quot;000655&quot;</td><td>&quot;金岭矿业&quot;</td><td>&quot;金岭矿业&quot;</td><td>6.48</td><td>7500.0</td><td>48600.0</td><td>7.78</td><td>48.61</td><td>0.47</td><td>0.0</td><td>48543.61</td></tr><tr><td>&quot;湘财&quot;</td><td>2023-06-01</td><td>10:45:35</td><td>&quot;300214&quot;</td><td>&quot;日科化学&quot;</td><td>&quot;日科化学&quot;</td><td>6.8</td><td>7400.0</td><td>50320.0</td><td>8.05</td><td>50.32</td><td>0.51</td><td>0.0</td><td>50261.63</td></tr><tr><td>&quot;湘财&quot;</td><td>2023-09-11</td><td>09:46:10</td><td>&quot;603577&quot;</td><td>&quot;汇金通&quot;</td><td>&quot;汇金通&quot;</td><td>9.3024</td><td>5100.0</td><td>47442.0</td><td>6.9</td><td>23.72</td><td>0.49</td><td>0.0</td><td>47410.89</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (257, 14)\n",
       "┌──────┬──────────┬─────────┬─────────┬───┬────────┬────────┬────────┬─────────┐\n",
       "│ 券商 ┆ 交易日期 ┆ 交易时  ┆ 证券代  ┆ … ┆ 印花税 ┆ 过户费 ┆ 其他费 ┆ 发生金  │\n",
       "│ ---  ┆ ---      ┆ 间      ┆ 码      ┆   ┆ ---    ┆ ---    ┆ ---    ┆ 额      │\n",
       "│ str  ┆ date     ┆ ---     ┆ ---     ┆   ┆ f64    ┆ f64    ┆ f64    ┆ ---     │\n",
       "│      ┆          ┆ time    ┆ str     ┆   ┆        ┆        ┆        ┆ f64     │\n",
       "╞══════╪══════════╪═════════╪═════════╪═══╪════════╪════════╪════════╪═════════╡\n",
       "│ 湘财 ┆ 2022-07- ┆ 09:38:1 ┆ 002462  ┆ … ┆ 137.35 ┆ 1.38   ┆ 0.0    ┆ 137184. │\n",
       "│      ┆ 18       ┆ 0       ┆         ┆   ┆        ┆        ┆        ┆ 67      │\n",
       "│ 湘财 ┆ 2022-07- ┆ 09:44:5 ┆ 600408  ┆ … ┆ 0.0    ┆ 1.51   ┆ 0.0    ┆ -149955 │\n",
       "│      ┆ 18       ┆ 2       ┆         ┆   ┆        ┆        ┆        ┆ .5      │\n",
       "│ 湘财 ┆ 2022-07- ┆ 09:44:3 ┆ 600648  ┆ … ┆ 0.0    ┆ 1.49   ┆ 0.0    ┆ -150044 │\n",
       "│      ┆ 18       ┆ 1       ┆         ┆   ┆        ┆        ┆        ┆ .49     │\n",
       "│ 湘财 ┆ 2022-07- ┆ 09:43:3 ┆ 600269  ┆ … ┆ 0.0    ┆ 1.5    ┆ 0.0    ┆ -150208 │\n",
       "│      ┆ 18       ┆ 8       ┆         ┆   ┆        ┆        ┆        ┆ .53     │\n",
       "│ 湘财 ┆ 2022-07- ┆ 09:42:5 ┆ 600015  ┆ … ┆ 0.0    ┆ 1.52   ┆ 0.0    ┆ -152125 │\n",
       "│      ┆ 18       ┆ 1       ┆         ┆   ┆        ┆        ┆        ┆ .86     │\n",
       "│ …    ┆ …        ┆ …       ┆ …       ┆ … ┆ …      ┆ …      ┆ …      ┆ …       │\n",
       "│ 湘财 ┆ 2023-06- ┆ 10:18:4 ┆ 603967  ┆ … ┆ 45.65  ┆ 0.46   ┆ 0.0    ┆ 45596.5 │\n",
       "│      ┆ 19       ┆ 6       ┆         ┆   ┆        ┆        ┆        ┆ 9       │\n",
       "│ 湘财 ┆ 2023-06- ┆ 13:22:3 ┆ 300641  ┆ … ┆ 48.48  ┆ 0.48   ┆ 0.0    ┆ 48423.7 │\n",
       "│      ┆ 12       ┆ 2       ┆         ┆   ┆        ┆        ┆        ┆ 6       │\n",
       "│ 湘财 ┆ 2023-06- ┆ 10:26:3 ┆ 000655  ┆ … ┆ 48.61  ┆ 0.47   ┆ 0.0    ┆ 48543.6 │\n",
       "│      ┆ 02       ┆ 5       ┆         ┆   ┆        ┆        ┆        ┆ 1       │\n",
       "│ 湘财 ┆ 2023-06- ┆ 10:45:3 ┆ 300214  ┆ … ┆ 50.32  ┆ 0.51   ┆ 0.0    ┆ 50261.6 │\n",
       "│      ┆ 01       ┆ 5       ┆         ┆   ┆        ┆        ┆        ┆ 3       │\n",
       "│ 湘财 ┆ 2023-09- ┆ 09:46:1 ┆ 603577  ┆ … ┆ 23.72  ┆ 0.49   ┆ 0.0    ┆ 47410.8 │\n",
       "│      ┆ 11       ┆ 0       ┆         ┆   ┆        ┆        ┆        ┆ 9       │\n",
       "└──────┴──────────┴─────────┴─────────┴───┴────────┴────────┴────────┴─────────┘"
      ]
     },
     "execution_count": 239,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d1.select(\n",
    "    券商=pl.col(\"券商\"),\n",
    "    交易日期=pl.col(\"交易日期\"),\n",
    "    交易时间=pl.col(\"交易时间\"),\n",
    "    证券代码=pl.col(\"证券代码\"),\n",
    "    证券名称=pl.col(\"证券名称\"),\n",
    "    买卖标志=pl.col(\"买卖标志\").replace({\"证券卖出\":\"卖出\",\"证券买入\":\"买入\"}),\n",
    "    成交价格=pl.col(\"成交价格\"),\n",
    "    成交数量=pl.col(\"成交数量\").abs(),\n",
    "    成交金额=pl.col(\"成交金额\"),\n",
    "    手续费=pl.col(\"手续费\"),\n",
    "    印花税=pl.col(\"印花税\"),\n",
    "    过户费=pl.col(\"过户费\"),\n",
    "    其他费=pl.col(\"其他费\"),\n",
    "    发生金额=pl.col(\"发生金额\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 244,
   "id": "8fd37bfc-ba1f-4b46-92e8-898cc2ac939b",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = d1.select(\n",
    "    券商=pl.col(\"券商\"),\n",
    "    交易日期=pl.col(\"交易日期\"),\n",
    "    交易时间=pl.col(\"交易时间\"),\n",
    "    证券代码=pl.col(\"证券代码\"),\n",
    "    证券名称=pl.col(\"证券名称\"),\n",
    "    买卖标志=pl.col(\"买卖标志\").replace({\"证券卖出\":\"卖出\",\"证券买入\":\"买入\"}),\n",
    "    成交价格=pl.col(\"成交价格\"),\n",
    "    成交数量=pl.col(\"成交数量\").abs(),\n",
    "    成交金额=pl.col(\"成交金额\"),\n",
    "    手续费=pl.col(\"手续费\"),\n",
    "    印花税=pl.col(\"印花税\"),\n",
    "    过户费=pl.col(\"过户费\"),\n",
    "    其他费=pl.col(\"其他费\"),\n",
    "    发生金额=pl.col(\"发生金额\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 245,
   "id": "34f78072-8b85-4836-ad88-52f1adce1f88",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (53, 14)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th></tr><tr><td>str</td><td>date</td><td>time</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;海通普通&quot;</td><td>2023-05-24</td><td>10:06:14</td><td>&quot;600626&quot;</td><td>&quot;申达股份&quot;</td><td>&quot;买入&quot;</td><td>3.37</td><td>14800.0</td><td>49876.0</td><td>4.99</td><td>0.0</td><td>0.49</td><td>0.0</td><td>-49881.48</td></tr><tr><td>&quot;海通普通&quot;</td><td>2023-05-24</td><td>09:59:17</td><td>&quot;600178&quot;</td><td>&quot;东安动力&quot;</td><td>&quot;买入&quot;</td><td>6.07</td><td>16400.0</td><td>99548.0</td><td>9.95</td><td>0.0</td><td>1.02</td><td>0.0</td><td>-99558.97</td></tr><tr><td>&quot;海通普通&quot;</td><td>2023-05-24</td><td>09:54:48</td><td>&quot;603002&quot;</td><td>&quot;宏昌电子&quot;</td><td>&quot;买入&quot;</td><td>5.06</td><td>9800.0</td><td>49588.0</td><td>4.96</td><td>0.0</td><td>0.5</td><td>0.0</td><td>-49593.46</td></tr><tr><td>&quot;海通普通&quot;</td><td>2023-05-23</td><td>10:01:57</td><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>&quot;买入&quot;</td><td>5.0</td><td>10000.0</td><td>50000.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-50005.0</td></tr><tr><td>&quot;海通普通&quot;</td><td>2023-05-23</td><td>09:58:07</td><td>&quot;002224&quot;</td><td>&quot;三 力 士&quot;</td><td>&quot;买入&quot;</td><td>4.59</td><td>10800.0</td><td>49572.0</td><td>4.96</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-49576.96</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;海通普通&quot;</td><td>2023-07-17</td><td>10:03:09</td><td>&quot;605196&quot;</td><td>&quot;华通线缆&quot;</td><td>&quot;卖出&quot;</td><td>7.81</td><td>7200.0</td><td>56232.0</td><td>5.62</td><td>56.23</td><td>0.56</td><td>0.0</td><td>56169.59</td></tr><tr><td>&quot;海通普通&quot;</td><td>2023-07-11</td><td>10:04:39</td><td>&quot;002842&quot;</td><td>&quot;翔鹭钨业&quot;</td><td>&quot;卖出&quot;</td><td>8.68</td><td>5900.0</td><td>51212.0</td><td>5.12</td><td>51.22</td><td>0.0</td><td>0.0</td><td>51155.66</td></tr><tr><td>&quot;海通普通&quot;</td><td>2023-07-11</td><td>10:03:52</td><td>&quot;002331&quot;</td><td>&quot;皖通科技&quot;</td><td>&quot;卖出&quot;</td><td>7.33</td><td>6900.0</td><td>50577.0</td><td>5.06</td><td>50.58</td><td>0.0</td><td>0.0</td><td>50521.36</td></tr><tr><td>&quot;海通普通&quot;</td><td>2023-07-11</td><td>10:13:04</td><td>&quot;600300&quot;</td><td>&quot;维维股份&quot;</td><td>&quot;买入&quot;</td><td>3.05</td><td>16400.0</td><td>50020.0</td><td>5.0</td><td>0.0</td><td>0.5</td><td>0.0</td><td>-50025.5</td></tr><tr><td>&quot;海通普通&quot;</td><td>2023-07-11</td><td>10:08:50</td><td>&quot;600287&quot;</td><td>&quot;江苏舜天&quot;</td><td>&quot;买入&quot;</td><td>5.06</td><td>9900.0</td><td>50094.0</td><td>5.01</td><td>0.0</td><td>0.5</td><td>0.0</td><td>-50099.51</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (53, 14)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 券商    ┆ 交易日  ┆ 交易时  ┆ 证券代 ┆ … ┆ 印花税 ┆ 过户费 ┆ 其他费 ┆ 发生金 │\n",
       "│ ---     ┆ 期      ┆ 间      ┆ 码     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ 额     │\n",
       "│ str     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ f64    ┆ f64    ┆ f64    ┆ ---    │\n",
       "│         ┆ date    ┆ time    ┆ str    ┆   ┆        ┆        ┆        ┆ f64    │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 海通普  ┆ 2023-05 ┆ 10:06:1 ┆ 600626 ┆ … ┆ 0.0    ┆ 0.49   ┆ 0.0    ┆ -49881 │\n",
       "│ 通      ┆ -24     ┆ 4       ┆        ┆   ┆        ┆        ┆        ┆ .48    │\n",
       "│ 海通普  ┆ 2023-05 ┆ 09:59:1 ┆ 600178 ┆ … ┆ 0.0    ┆ 1.02   ┆ 0.0    ┆ -99558 │\n",
       "│ 通      ┆ -24     ┆ 7       ┆        ┆   ┆        ┆        ┆        ┆ .97    │\n",
       "│ 海通普  ┆ 2023-05 ┆ 09:54:4 ┆ 603002 ┆ … ┆ 0.0    ┆ 0.5    ┆ 0.0    ┆ -49593 │\n",
       "│ 通      ┆ -24     ┆ 8       ┆        ┆   ┆        ┆        ┆        ┆ .46    │\n",
       "│ 海通普  ┆ 2023-05 ┆ 10:01:5 ┆ 300107 ┆ … ┆ 0.0    ┆ 0.0    ┆ 0.0    ┆ -50005 │\n",
       "│ 通      ┆ -23     ┆ 7       ┆        ┆   ┆        ┆        ┆        ┆ .0     │\n",
       "│ 海通普  ┆ 2023-05 ┆ 09:58:0 ┆ 002224 ┆ … ┆ 0.0    ┆ 0.0    ┆ 0.0    ┆ -49576 │\n",
       "│ 通      ┆ -23     ┆ 7       ┆        ┆   ┆        ┆        ┆        ┆ .96    │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 海通普  ┆ 2023-07 ┆ 10:03:0 ┆ 605196 ┆ … ┆ 56.23  ┆ 0.56   ┆ 0.0    ┆ 56169. │\n",
       "│ 通      ┆ -17     ┆ 9       ┆        ┆   ┆        ┆        ┆        ┆ 59     │\n",
       "│ 海通普  ┆ 2023-07 ┆ 10:04:3 ┆ 002842 ┆ … ┆ 51.22  ┆ 0.0    ┆ 0.0    ┆ 51155. │\n",
       "│ 通      ┆ -11     ┆ 9       ┆        ┆   ┆        ┆        ┆        ┆ 66     │\n",
       "│ 海通普  ┆ 2023-07 ┆ 10:03:5 ┆ 002331 ┆ … ┆ 50.58  ┆ 0.0    ┆ 0.0    ┆ 50521. │\n",
       "│ 通      ┆ -11     ┆ 2       ┆        ┆   ┆        ┆        ┆        ┆ 36     │\n",
       "│ 海通普  ┆ 2023-07 ┆ 10:13:0 ┆ 600300 ┆ … ┆ 0.0    ┆ 0.5    ┆ 0.0    ┆ -50025 │\n",
       "│ 通      ┆ -11     ┆ 4       ┆        ┆   ┆        ┆        ┆        ┆ .5     │\n",
       "│ 海通普  ┆ 2023-07 ┆ 10:08:5 ┆ 600287 ┆ … ┆ 0.0    ┆ 0.5    ┆ 0.0    ┆ -50099 │\n",
       "│ 通      ┆ -11     ┆ 0       ┆        ┆   ┆        ┆        ┆        ┆ .51    │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 245,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 241,
   "id": "88de9c78-2f0e-4502-a4fb-43f488f9a0e7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (53, 15)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>券商</th></tr><tr><td>str</td><td>str</td><td>date</td><td>time</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;600626&quot;</td><td>&quot;申达股份&quot;</td><td>2023-05-24</td><td>10:06:14</td><td>14800.0</td><td>3.37</td><td>49876.0</td><td>-49881.48</td><td>&quot;买&quot;</td><td>4.99</td><td>0.0</td><td>0.49</td><td>0.0</td><td>&quot;申达股份证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;600178&quot;</td><td>&quot;东安动力&quot;</td><td>2023-05-24</td><td>09:59:17</td><td>16400.0</td><td>6.07</td><td>99548.0</td><td>-99558.97</td><td>&quot;买&quot;</td><td>9.95</td><td>0.0</td><td>1.02</td><td>0.0</td><td>&quot;东安动力证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;603002&quot;</td><td>&quot;宏昌电子&quot;</td><td>2023-05-24</td><td>09:54:48</td><td>9800.0</td><td>5.06</td><td>49588.0</td><td>-49593.46</td><td>&quot;买&quot;</td><td>4.96</td><td>0.0</td><td>0.5</td><td>0.0</td><td>&quot;宏昌电子证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>2023-05-23</td><td>10:01:57</td><td>10000.0</td><td>5.0</td><td>50000.0</td><td>-50005.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;建新股份证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;002224&quot;</td><td>&quot;三 力 士&quot;</td><td>2023-05-23</td><td>09:58:07</td><td>10800.0</td><td>4.59</td><td>49572.0</td><td>-49576.96</td><td>&quot;买&quot;</td><td>4.96</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;三 力 士证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;605196&quot;</td><td>&quot;华通线缆&quot;</td><td>2023-07-17</td><td>10:03:09</td><td>7200.0</td><td>7.81</td><td>56232.0</td><td>56169.59</td><td>&quot;卖&quot;</td><td>5.62</td><td>56.23</td><td>0.56</td><td>0.0</td><td>&quot;华通线缆证券卖出&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;002842&quot;</td><td>&quot;翔鹭钨业&quot;</td><td>2023-07-11</td><td>10:04:39</td><td>5900.0</td><td>8.68</td><td>51212.0</td><td>51155.66</td><td>&quot;卖&quot;</td><td>5.12</td><td>51.22</td><td>0.0</td><td>0.0</td><td>&quot;翔鹭钨业证券卖出&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;002331&quot;</td><td>&quot;皖通科技&quot;</td><td>2023-07-11</td><td>10:03:52</td><td>6900.0</td><td>7.33</td><td>50577.0</td><td>50521.36</td><td>&quot;卖&quot;</td><td>5.06</td><td>50.58</td><td>0.0</td><td>0.0</td><td>&quot;皖通科技证券卖出&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;600300&quot;</td><td>&quot;维维股份&quot;</td><td>2023-07-11</td><td>10:13:04</td><td>16400.0</td><td>3.05</td><td>50020.0</td><td>-50025.5</td><td>&quot;买&quot;</td><td>5.0</td><td>0.0</td><td>0.5</td><td>0.0</td><td>&quot;维维股份证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;600287&quot;</td><td>&quot;江苏舜天&quot;</td><td>2023-07-11</td><td>10:08:50</td><td>9900.0</td><td>5.06</td><td>50094.0</td><td>-50099.51</td><td>&quot;买&quot;</td><td>5.01</td><td>0.0</td><td>0.5</td><td>0.0</td><td>&quot;江苏舜天证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (53, 15)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 证券代  ┆ 证券名  ┆ 成交日  ┆ 成交时 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 券商   │\n",
       "│ 码      ┆ 称      ┆ 期      ┆ 间     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ f64    ┆ f64    ┆ str    ┆ str    │\n",
       "│ str     ┆ str     ┆ date    ┆ time   ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 600626  ┆ 申达股  ┆ 2023-05 ┆ 10:06: ┆ … ┆ 0.49   ┆ 0.0    ┆ 申达股 ┆ 海通普 │\n",
       "│         ┆ 份      ┆ -24     ┆ 14     ┆   ┆        ┆        ┆ 份证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 600178  ┆ 东安动  ┆ 2023-05 ┆ 09:59: ┆ … ┆ 1.02   ┆ 0.0    ┆ 东安动 ┆ 海通普 │\n",
       "│         ┆ 力      ┆ -24     ┆ 17     ┆   ┆        ┆        ┆ 力证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 603002  ┆ 宏昌电  ┆ 2023-05 ┆ 09:54: ┆ … ┆ 0.5    ┆ 0.0    ┆ 宏昌电 ┆ 海通普 │\n",
       "│         ┆ 子      ┆ -24     ┆ 48     ┆   ┆        ┆        ┆ 子证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 300107  ┆ 建新股  ┆ 2023-05 ┆ 10:01: ┆ … ┆ 0.0    ┆ 0.0    ┆ 建新股 ┆ 海通普 │\n",
       "│         ┆ 份      ┆ -23     ┆ 57     ┆   ┆        ┆        ┆ 份证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 002224  ┆ 三 力   ┆ 2023-05 ┆ 09:58: ┆ … ┆ 0.0    ┆ 0.0    ┆ 三 力  ┆ 海通普 │\n",
       "│         ┆ 士      ┆ -23     ┆ 07     ┆   ┆        ┆        ┆ 士证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 605196  ┆ 华通线  ┆ 2023-07 ┆ 10:03: ┆ … ┆ 0.56   ┆ 0.0    ┆ 华通线 ┆ 海通普 │\n",
       "│         ┆ 缆      ┆ -17     ┆ 09     ┆   ┆        ┆        ┆ 缆证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 卖出   ┆        │\n",
       "│ 002842  ┆ 翔鹭钨  ┆ 2023-07 ┆ 10:04: ┆ … ┆ 0.0    ┆ 0.0    ┆ 翔鹭钨 ┆ 海通普 │\n",
       "│         ┆ 业      ┆ -11     ┆ 39     ┆   ┆        ┆        ┆ 业证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 卖出   ┆        │\n",
       "│ 002331  ┆ 皖通科  ┆ 2023-07 ┆ 10:03: ┆ … ┆ 0.0    ┆ 0.0    ┆ 皖通科 ┆ 海通普 │\n",
       "│         ┆ 技      ┆ -11     ┆ 52     ┆   ┆        ┆        ┆ 技证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 卖出   ┆        │\n",
       "│ 600300  ┆ 维维股  ┆ 2023-07 ┆ 10:13: ┆ … ┆ 0.5    ┆ 0.0    ┆ 维维股 ┆ 海通普 │\n",
       "│         ┆ 份      ┆ -11     ┆ 04     ┆   ┆        ┆        ┆ 份证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 600287  ┆ 江苏舜  ┆ 2023-07 ┆ 10:08: ┆ … ┆ 0.5    ┆ 0.0    ┆ 江苏舜 ┆ 海通普 │\n",
       "│         ┆ 天      ┆ -11     ┆ 50     ┆   ┆        ┆        ┆ 天证券 ┆ 通     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 241,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = [read_df_海通普通(p) for p in Path(\"stock_trades/\").glob(\"*-海通普通.xlsx\")]\n",
    "df= pl.concat(df)\n",
    "d1 = df.with_columns(\n",
    "    券商=pl.lit(\"海通普通\"),\n",
    ")\n",
    "d1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 216,
   "id": "f7afd26b-852d-4756-b03d-633bec232483",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (53, 13)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th></tr><tr><td>str</td><td>date</td><td>time</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;海通两融&quot;</td><td>2023-07-26</td><td>09:33:56</td><td>&quot;600638&quot;</td><td>&quot;新黄浦&quot;</td><td>&quot;卖出&quot;</td><td>6.526</td><td>9300.0</td><td>60696.0</td><td>6.68</td><td>60.7</td><td>0.61</td><td>0.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-07-27</td><td>09:30:42</td><td>&quot;002492&quot;</td><td>&quot;恒基达鑫&quot;</td><td>&quot;卖出&quot;</td><td>6.12</td><td>8700.0</td><td>53244.0</td><td>5.86</td><td>53.23</td><td>0.0</td><td>0.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-07-27</td><td>09:32:52</td><td>&quot;002136&quot;</td><td>&quot;安 纳 达&quot;</td><td>&quot;卖出&quot;</td><td>11.881</td><td>4400.0</td><td>52277.0</td><td>5.75</td><td>52.28</td><td>0.0</td><td>0.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-08-22</td><td>09:36:13</td><td>&quot;603967&quot;</td><td>&quot;中创物流&quot;</td><td>&quot;卖出&quot;</td><td>9.36</td><td>10600.0</td><td>99216.0</td><td>10.91</td><td>99.24</td><td>1.0</td><td>0.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-08-04</td><td>10:07:37</td><td>&quot;603967&quot;</td><td>&quot;中创物流&quot;</td><td>&quot;买入&quot;</td><td>9.43</td><td>10600.0</td><td>99958.0</td><td>11.0</td><td>0.0</td><td>1.01</td><td>0.0</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-18</td><td>09:46:15</td><td>&quot;300464&quot;</td><td>&quot;星徽股份&quot;</td><td>&quot;卖出&quot;</td><td>5.74</td><td>16100.0</td><td>92414.0</td><td>8.82</td><td>46.21</td><td>0.0</td><td>0.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-18</td><td>09:55:41</td><td>&quot;002661&quot;</td><td>&quot;克明食品&quot;</td><td>&quot;买入&quot;</td><td>9.42</td><td>8500.0</td><td>80072.0</td><td>7.64</td><td>0.0</td><td>0.0</td><td>0.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-09</td><td>09:48:02</td><td>&quot;002753&quot;</td><td>&quot;永东股份&quot;</td><td>&quot;买入&quot;</td><td>7.02</td><td>14200.0</td><td>99684.0</td><td>9.51</td><td>0.0</td><td>0.0</td><td>0.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-09</td><td>09:45:18</td><td>&quot;000698&quot;</td><td>&quot;沈阳化工&quot;</td><td>&quot;卖出&quot;</td><td>4.053</td><td>23800.0</td><td>96460.0</td><td>9.2</td><td>48.24</td><td>0.0</td><td>0.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-09</td><td>09:44:40</td><td>&quot;605288&quot;</td><td>&quot;凯迪股份&quot;</td><td>&quot;卖出&quot;</td><td>40.838</td><td>2500.0</td><td>102094.0</td><td>9.74</td><td>51.05</td><td>1.0</td><td>0.0</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (53, 13)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 券商    ┆ 交易日  ┆ 交易时  ┆ 证券代 ┆ … ┆ 手续费 ┆ 印花税 ┆ 过户费 ┆ 其他费 │\n",
       "│ ---     ┆ 期      ┆ 间      ┆ 码     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ str     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ f64    ┆ f64    ┆ f64    ┆ f64    │\n",
       "│         ┆ date    ┆ time    ┆ str    ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 海通两  ┆ 2023-07 ┆ 09:33:5 ┆ 600638 ┆ … ┆ 6.68   ┆ 60.7   ┆ 0.61   ┆ 0.0    │\n",
       "│ 融      ┆ -26     ┆ 6       ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ 海通两  ┆ 2023-07 ┆ 09:30:4 ┆ 002492 ┆ … ┆ 5.86   ┆ 53.23  ┆ 0.0    ┆ 0.0    │\n",
       "│ 融      ┆ -27     ┆ 2       ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ 海通两  ┆ 2023-07 ┆ 09:32:5 ┆ 002136 ┆ … ┆ 5.75   ┆ 52.28  ┆ 0.0    ┆ 0.0    │\n",
       "│ 融      ┆ -27     ┆ 2       ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ 海通两  ┆ 2023-08 ┆ 09:36:1 ┆ 603967 ┆ … ┆ 10.91  ┆ 99.24  ┆ 1.0    ┆ 0.0    │\n",
       "│ 融      ┆ -22     ┆ 3       ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ 海通两  ┆ 2023-08 ┆ 10:07:3 ┆ 603967 ┆ … ┆ 11.0   ┆ 0.0    ┆ 1.01   ┆ 0.0    │\n",
       "│ 融      ┆ -04     ┆ 7       ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:46:1 ┆ 300464 ┆ … ┆ 8.82   ┆ 46.21  ┆ 0.0    ┆ 0.0    │\n",
       "│ 融      ┆ -18     ┆ 5       ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:55:4 ┆ 002661 ┆ … ┆ 7.64   ┆ 0.0    ┆ 0.0    ┆ 0.0    │\n",
       "│ 融      ┆ -18     ┆ 1       ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:48:0 ┆ 002753 ┆ … ┆ 9.51   ┆ 0.0    ┆ 0.0    ┆ 0.0    │\n",
       "│ 融      ┆ -09     ┆ 2       ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:45:1 ┆ 000698 ┆ … ┆ 9.2    ┆ 48.24  ┆ 0.0    ┆ 0.0    │\n",
       "│ 融      ┆ -09     ┆ 8       ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:44:4 ┆ 605288 ┆ … ┆ 9.74   ┆ 51.05  ┆ 1.0    ┆ 0.0    │\n",
       "│ 融      ┆ -09     ┆ 0       ┆        ┆   ┆        ┆        ┆        ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 216,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 217,
   "id": "a00b1c8d-f6c5-431e-80c7-7e378f08ac8e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (53, 15)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>券商</th></tr><tr><td>str</td><td>str</td><td>date</td><td>time</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;600638&quot;</td><td>&quot;新黄浦&quot;</td><td>2023-07-26</td><td>09:33:56</td><td>9300.0</td><td>6.526</td><td>60696.0</td><td>60628.01</td><td>&quot;卖&quot;</td><td>6.68</td><td>60.7</td><td>0.61</td><td>0.0</td><td>&quot;新黄浦证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;002492&quot;</td><td>&quot;恒基达鑫&quot;</td><td>2023-07-27</td><td>09:30:42</td><td>8700.0</td><td>6.12</td><td>53244.0</td><td>53184.91</td><td>&quot;卖&quot;</td><td>5.86</td><td>53.23</td><td>0.0</td><td>0.0</td><td>&quot;恒基达鑫证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;002136&quot;</td><td>&quot;安 纳 达&quot;</td><td>2023-07-27</td><td>09:32:52</td><td>4400.0</td><td>11.881</td><td>52277.0</td><td>52218.97</td><td>&quot;卖&quot;</td><td>5.75</td><td>52.28</td><td>0.0</td><td>0.0</td><td>&quot;安 纳 达证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;603967&quot;</td><td>&quot;中创物流&quot;</td><td>2023-08-22</td><td>09:36:13</td><td>10600.0</td><td>9.36</td><td>99216.0</td><td>99104.85</td><td>&quot;卖&quot;</td><td>10.91</td><td>99.24</td><td>1.0</td><td>0.0</td><td>&quot;中创物流证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;603967&quot;</td><td>&quot;中创物流&quot;</td><td>2023-08-04</td><td>10:07:37</td><td>10600.0</td><td>9.43</td><td>99958.0</td><td>-99970.01</td><td>&quot;买&quot;</td><td>11.0</td><td>0.0</td><td>1.01</td><td>0.0</td><td>&quot;中创物流证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;300464&quot;</td><td>&quot;星徽股份&quot;</td><td>2023-10-18</td><td>09:46:15</td><td>16100.0</td><td>5.74</td><td>92414.0</td><td>92358.97</td><td>&quot;卖&quot;</td><td>8.82</td><td>46.21</td><td>0.0</td><td>0.0</td><td>&quot;星徽股份证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;002661&quot;</td><td>&quot;克明食品&quot;</td><td>2023-10-18</td><td>09:55:41</td><td>8500.0</td><td>9.42</td><td>80072.0</td><td>-80079.64</td><td>&quot;买&quot;</td><td>7.64</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;克明食品证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;002753&quot;</td><td>&quot;永东股份&quot;</td><td>2023-10-09</td><td>09:48:02</td><td>14200.0</td><td>7.02</td><td>99684.0</td><td>-99693.51</td><td>&quot;买&quot;</td><td>9.51</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;永东股份证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;000698&quot;</td><td>&quot;沈阳化工&quot;</td><td>2023-10-09</td><td>09:45:18</td><td>23800.0</td><td>4.053</td><td>96460.0</td><td>96402.56</td><td>&quot;卖&quot;</td><td>9.2</td><td>48.24</td><td>0.0</td><td>0.0</td><td>&quot;沈阳化工证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;605288&quot;</td><td>&quot;凯迪股份&quot;</td><td>2023-10-09</td><td>09:44:40</td><td>2500.0</td><td>40.838</td><td>102094.0</td><td>102032.21</td><td>&quot;卖&quot;</td><td>9.74</td><td>51.05</td><td>1.0</td><td>0.0</td><td>&quot;凯迪股份证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (53, 15)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 证券代  ┆ 证券名  ┆ 成交日  ┆ 成交时 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注   ┆ 券商   │\n",
       "│ 码      ┆ 称      ┆ 期      ┆ 间     ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ f64    ┆ f64    ┆ str    ┆ str    │\n",
       "│ str     ┆ str     ┆ date    ┆ time   ┆   ┆        ┆        ┆        ┆        │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 600638  ┆ 新黄浦  ┆ 2023-07 ┆ 09:33: ┆ … ┆ 0.61   ┆ 0.0    ┆ 新黄浦 ┆ 海通两 │\n",
       "│         ┆         ┆ -26     ┆ 56     ┆   ┆        ┆        ┆ 证券卖 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 出     ┆        │\n",
       "│ 002492  ┆ 恒基达  ┆ 2023-07 ┆ 09:30: ┆ … ┆ 0.0    ┆ 0.0    ┆ 恒基达 ┆ 海通两 │\n",
       "│         ┆ 鑫      ┆ -27     ┆ 42     ┆   ┆        ┆        ┆ 鑫证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 卖出   ┆        │\n",
       "│ 002136  ┆ 安 纳   ┆ 2023-07 ┆ 09:32: ┆ … ┆ 0.0    ┆ 0.0    ┆ 安 纳  ┆ 海通两 │\n",
       "│         ┆ 达      ┆ -27     ┆ 52     ┆   ┆        ┆        ┆ 达证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 卖出   ┆        │\n",
       "│ 603967  ┆ 中创物  ┆ 2023-08 ┆ 09:36: ┆ … ┆ 1.0    ┆ 0.0    ┆ 中创物 ┆ 海通两 │\n",
       "│         ┆ 流      ┆ -22     ┆ 13     ┆   ┆        ┆        ┆ 流证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 卖出   ┆        │\n",
       "│ 603967  ┆ 中创物  ┆ 2023-08 ┆ 10:07: ┆ … ┆ 1.01   ┆ 0.0    ┆ 中创物 ┆ 海通两 │\n",
       "│         ┆ 流      ┆ -04     ┆ 37     ┆   ┆        ┆        ┆ 流证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 300464  ┆ 星徽股  ┆ 2023-10 ┆ 09:46: ┆ … ┆ 0.0    ┆ 0.0    ┆ 星徽股 ┆ 海通两 │\n",
       "│         ┆ 份      ┆ -18     ┆ 15     ┆   ┆        ┆        ┆ 份证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 卖出   ┆        │\n",
       "│ 002661  ┆ 克明食  ┆ 2023-10 ┆ 09:55: ┆ … ┆ 0.0    ┆ 0.0    ┆ 克明食 ┆ 海通两 │\n",
       "│         ┆ 品      ┆ -18     ┆ 41     ┆   ┆        ┆        ┆ 品证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 002753  ┆ 永东股  ┆ 2023-10 ┆ 09:48: ┆ … ┆ 0.0    ┆ 0.0    ┆ 永东股 ┆ 海通两 │\n",
       "│         ┆ 份      ┆ -09     ┆ 02     ┆   ┆        ┆        ┆ 份证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 买入   ┆        │\n",
       "│ 000698  ┆ 沈阳化  ┆ 2023-10 ┆ 09:45: ┆ … ┆ 0.0    ┆ 0.0    ┆ 沈阳化 ┆ 海通两 │\n",
       "│         ┆ 工      ┆ -09     ┆ 18     ┆   ┆        ┆        ┆ 工证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 卖出   ┆        │\n",
       "│ 605288  ┆ 凯迪股  ┆ 2023-10 ┆ 09:44: ┆ … ┆ 1.0    ┆ 0.0    ┆ 凯迪股 ┆ 海通两 │\n",
       "│         ┆ 份      ┆ -09     ┆ 40     ┆   ┆        ┆        ┆ 份证券 ┆ 融     │\n",
       "│         ┆         ┆         ┆        ┆   ┆        ┆        ┆ 卖出   ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 217,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = [read_df_海通普通(p) for p in Path(\"stock_trades/\").glob(\"*-海通两融.xlsx\")]\n",
    "df= pl.concat(df)\n",
    "d3 = df.with_columns(\n",
    "    券商=pl.lit(\"海通两融\"),\n",
    ")\n",
    "d3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 221,
   "id": "117e788b-47d5-4790-9169-8f23128af134",
   "metadata": {},
   "outputs": [],
   "source": [
    "d3 = d3.select(\n",
    "    券商=pl.col(\"券商\"),\n",
    "    交易日期=pl.col(\"成交日期\"),\n",
    "    交易时间=pl.col(\"成交时间\"),\n",
    "    证券代码=pl.col(\"证券代码\"),\n",
    "    证券名称=pl.col(\"证券名称\"),\n",
    "    买卖标志=pl.col(\"操作\").replace({\"卖\":\"卖出\",\"买\":\"买入\"}),\n",
    "    成交价格=pl.col(\"成交价格\"),\n",
    "    成交数量=pl.col(\"成交数量\").abs(),\n",
    "    成交金额=pl.col(\"成交金额\"),\n",
    "    手续费=pl.col(\"手续费\"),\n",
    "    印花税=pl.col(\"印花税\"),\n",
    "    过户费=pl.col(\"过户费\"),\n",
    "    其他费=pl.col(\"其他费\"),\n",
    "    发生金额=pl.col(\"发生金额\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 253,
   "id": "ce712435-b85b-4c48-8f4a-587962c7c348",
   "metadata": {},
   "outputs": [],
   "source": [
    "def read_df_湘财(f: str | Path) -> pl.DataFrame:\n",
    "    df = pl.read_csv(\n",
    "        f,\n",
    "        encoding=\"gb18030\",\n",
    "        separator=\"\\t\",\n",
    "        infer_schema=False,\n",
    "    )\n",
    "    df = df.with_columns(\n",
    "        pl.selectors.all().str.strip_prefix(\"=\").str.strip_chars('\"'),\n",
    "    ).with_columns(\n",
    "        pl.col(\"发生日期\").str.to_date(\"%Y%m%d\"),\n",
    "        pl.col(\"成交时间\").str.to_time(),\n",
    "        pl.col(\n",
    "            \"成交数量\", \n",
    "            \"成交价格\", \n",
    "            \"成交金额\", \n",
    "            \"发生金额\", \n",
    "            \"手续费\", \n",
    "            \"印花税\", \n",
    "            \"过户费\", \n",
    "            \"其他费\"\n",
    "        ).cast(pl.Float64),\n",
    "    )\n",
    "    df = df.filter(\n",
    "        pl.col(\"业务名称\").is_in([\"证券买入\", \"证券卖出\"]),  \n",
    "    )\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 254,
   "id": "12b2d0e9-494a-43f0-8a2c-d26a38ea707f",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = [read_df_湘财(f) for f in Path(\"stock_trades/\").glob(\"*-湘财.xls\")]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 256,
   "id": "69dfad62-4ac9-49c8-b4cc-27d00c7ad656",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = pl.concat(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 257,
   "id": "97056140-6c6a-4f96-bc2e-b3c716a60fd7",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = d1.with_columns(\n",
    "    券商=pl.lit(\"湘财\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 258,
   "id": "921a8791-eb69-433f-9b6c-88e4bbaa3da0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (257, 17)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th><th>券商</th></tr><tr><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>time</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>2022-07-18</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>09:38:10</td><td>-10400.0</td><td>13.2062</td><td>137344.0</td><td>137184.67</td><td>21.98</td><td>137.35</td><td>1.38</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:44:52</td><td>47000.0</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>23.99</td><td>0.0</td><td>1.51</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:44:31</td><td>11900.0</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>24.0</td><td>0.0</td><td>1.49</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:43:38</td><td>40700.0</td><td>3.69</td><td>150183.0</td><td>-150208.53</td><td>24.03</td><td>0.0</td><td>1.5</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600015&quot;</td><td>&quot;华夏银行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:42:51</td><td>30000.0</td><td>5.07</td><td>152100.0</td><td>-152125.86</td><td>24.34</td><td>0.0</td><td>1.52</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>2023-06-19</td><td>&quot;603967&quot;</td><td>&quot;中创物流&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>10:18:46</td><td>-5000.0</td><td>9.13</td><td>45650.0</td><td>45596.59</td><td>7.3</td><td>45.65</td><td>0.46</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2023-06-12</td><td>&quot;300641&quot;</td><td>&quot;正丹股份&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>13:22:32</td><td>-9600.0</td><td>5.05</td><td>48480.0</td><td>48423.76</td><td>7.76</td><td>48.48</td><td>0.48</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2023-06-02</td><td>&quot;000655&quot;</td><td>&quot;金岭矿业&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>10:26:35</td><td>-7500.0</td><td>6.48</td><td>48600.0</td><td>48543.61</td><td>7.78</td><td>48.61</td><td>0.47</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2023-06-01</td><td>&quot;300214&quot;</td><td>&quot;日科化学&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>10:45:35</td><td>-7400.0</td><td>6.8</td><td>50320.0</td><td>50261.63</td><td>8.05</td><td>50.32</td><td>0.51</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2023-09-11</td><td>&quot;603577&quot;</td><td>&quot;汇金通&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>09:46:10</td><td>-5100.0</td><td>9.3024</td><td>47442.0</td><td>47410.89</td><td>6.9</td><td>23.72</td><td>0.49</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (257, 17)\n",
       "┌─────────┬─────────┬─────────┬─────────┬───┬────────┬─────────┬────────┬──────┐\n",
       "│ 发生日  ┆ 证券代  ┆ 证券名  ┆ 买卖标  ┆ … ┆ 其他费 ┆ 备注    ┆ 币种   ┆ 券商 │\n",
       "│ 期      ┆ 码      ┆ 称      ┆ 志      ┆   ┆ ---    ┆ ---     ┆ ---    ┆ ---  │\n",
       "│ ---     ┆ ---     ┆ ---     ┆ ---     ┆   ┆ f64    ┆ str     ┆ str    ┆ str  │\n",
       "│ date    ┆ str     ┆ str     ┆ str     ┆   ┆        ┆         ┆        ┆      │\n",
       "╞═════════╪═════════╪═════════╪═════════╪═══╪════════╪═════════╪════════╪══════╡\n",
       "│ 2022-07 ┆ 002462  ┆ 嘉事堂  ┆ 卖出    ┆ … ┆ 0.0    ┆ 证券卖  ┆ 人民币 ┆ 湘财 │\n",
       "│ -18     ┆         ┆         ┆         ┆   ┆        ┆ 出      ┆        ┆      │\n",
       "│ 2022-07 ┆ 600408  ┆ 安泰集  ┆ 买入    ┆ … ┆ 0.0    ┆ 证券买  ┆ 人民币 ┆ 湘财 │\n",
       "│ -18     ┆         ┆ 团      ┆         ┆   ┆        ┆ 入      ┆        ┆      │\n",
       "│ 2022-07 ┆ 600648  ┆ 外高桥  ┆ 买入    ┆ … ┆ 0.0    ┆ 证券买  ┆ 人民币 ┆ 湘财 │\n",
       "│ -18     ┆         ┆         ┆         ┆   ┆        ┆ 入      ┆        ┆      │\n",
       "│ 2022-07 ┆ 600269  ┆ 赣粤高  ┆ 买入    ┆ … ┆ 0.0    ┆ 证券买  ┆ 人民币 ┆ 湘财 │\n",
       "│ -18     ┆         ┆ 速      ┆         ┆   ┆        ┆ 入      ┆        ┆      │\n",
       "│ 2022-07 ┆ 600015  ┆ 华夏银  ┆ 买入    ┆ … ┆ 0.0    ┆ 证券买  ┆ 人民币 ┆ 湘财 │\n",
       "│ -18     ┆         ┆ 行      ┆         ┆   ┆        ┆ 入      ┆        ┆      │\n",
       "│ …       ┆ …       ┆ …       ┆ …       ┆ … ┆ …      ┆ …       ┆ …      ┆ …    │\n",
       "│ 2023-06 ┆ 603967  ┆ 中创物  ┆ 卖出    ┆ … ┆ 0.0    ┆ 证券卖  ┆ 人民币 ┆ 湘财 │\n",
       "│ -19     ┆         ┆ 流      ┆         ┆   ┆        ┆ 出      ┆        ┆      │\n",
       "│ 2023-06 ┆ 300641  ┆ 正丹股  ┆ 卖出    ┆ … ┆ 0.0    ┆ 证券卖  ┆ 人民币 ┆ 湘财 │\n",
       "│ -12     ┆         ┆ 份      ┆         ┆   ┆        ┆ 出      ┆        ┆      │\n",
       "│ 2023-06 ┆ 000655  ┆ 金岭矿  ┆ 卖出    ┆ … ┆ 0.0    ┆ 证券卖  ┆ 人民币 ┆ 湘财 │\n",
       "│ -02     ┆         ┆ 业      ┆         ┆   ┆        ┆ 出      ┆        ┆      │\n",
       "│ 2023-06 ┆ 300214  ┆ 日科化  ┆ 卖出    ┆ … ┆ 0.0    ┆ 证券卖  ┆ 人民币 ┆ 湘财 │\n",
       "│ -01     ┆         ┆ 学      ┆         ┆   ┆        ┆ 出      ┆        ┆      │\n",
       "│ 2023-09 ┆ 603577  ┆ 汇金通  ┆ 卖出    ┆ … ┆ 0.0    ┆ 证券卖  ┆ 人民币 ┆ 湘财 │\n",
       "│ -11     ┆         ┆         ┆         ┆   ┆        ┆ 出      ┆        ┆      │\n",
       "└─────────┴─────────┴─────────┴─────────┴───┴────────┴─────────┴────────┴──────┘"
      ]
     },
     "execution_count": 258,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 259,
   "id": "73278bcb-72c9-4b46-bbef-a1b5dd425b8b",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = d1.select(\n",
    "    券商=pl.col(\"券商\"),\n",
    "    交易日期=pl.col(\"发生日期\"),\n",
    "    交易时间=pl.col(\"成交时间\"),\n",
    "    证券代码=pl.col(\"证券代码\"),\n",
    "    证券名称=pl.col(\"证券名称\"),\n",
    "    买卖标志=pl.col(\"买卖标志\").replace({\"证券卖出\":\"卖出\",\"证券买入\":\"买入\"}),\n",
    "    成交价格=pl.col(\"成交价格\"),\n",
    "    成交数量=pl.col(\"成交数量\").abs(),\n",
    "    成交金额=pl.col(\"成交金额\"),\n",
    "    手续费=pl.col(\"手续费\"),\n",
    "    印花税=pl.col(\"印花税\"),\n",
    "    过户费=pl.col(\"过户费\"),\n",
    "    其他费=pl.col(\"其他费\"),\n",
    "    发生金额=pl.col(\"发生金额\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 265,
   "id": "8275ea37-4185-45a0-a1ef-f6e798af6b75",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "df = pl.concat([d1, d2, d3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 266,
   "id": "89912613-58c4-4c36-a74a-664838d344aa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (363, 3)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>成交金额</th><th>成交金额2</th><th>成交金额D</th></tr><tr><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>137344.0</td><td>137344.48</td><td>-0.48</td></tr><tr><td>149930.0</td><td>149930.0</td><td>0.0</td></tr><tr><td>150019.0</td><td>150018.54</td><td>0.46</td></tr><tr><td>150183.0</td><td>150183.0</td><td>0.0</td></tr><tr><td>152100.0</td><td>152100.0</td><td>0.0</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>92414.0</td><td>92414.0</td><td>0.0</td></tr><tr><td>80072.0</td><td>80070.0</td><td>2.0</td></tr><tr><td>99684.0</td><td>99684.0</td><td>0.0</td></tr><tr><td>96460.0</td><td>96461.4</td><td>-1.4</td></tr><tr><td>102094.0</td><td>102095.0</td><td>-1.0</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (363, 3)\n",
       "┌──────────┬───────────┬───────────┐\n",
       "│ 成交金额 ┆ 成交金额2 ┆ 成交金额D │\n",
       "│ ---      ┆ ---       ┆ ---       │\n",
       "│ f64      ┆ f64       ┆ f64       │\n",
       "╞══════════╪═══════════╪═══════════╡\n",
       "│ 137344.0 ┆ 137344.48 ┆ -0.48     │\n",
       "│ 149930.0 ┆ 149930.0  ┆ 0.0       │\n",
       "│ 150019.0 ┆ 150018.54 ┆ 0.46      │\n",
       "│ 150183.0 ┆ 150183.0  ┆ 0.0       │\n",
       "│ 152100.0 ┆ 152100.0  ┆ 0.0       │\n",
       "│ …        ┆ …         ┆ …         │\n",
       "│ 92414.0  ┆ 92414.0   ┆ 0.0       │\n",
       "│ 80072.0  ┆ 80070.0   ┆ 2.0       │\n",
       "│ 99684.0  ┆ 99684.0   ┆ 0.0       │\n",
       "│ 96460.0  ┆ 96461.4   ┆ -1.4      │\n",
       "│ 102094.0 ┆ 102095.0  ┆ -1.0      │\n",
       "└──────────┴───────────┴───────────┘"
      ]
     },
     "execution_count": 266,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.select(\n",
    "    \"成交金额\",\n",
    "    成交金额2=pl.col(\"成交价格\") * pl.col(\"成交数量\"),\n",
    ").with_columns(\n",
    "    成交金额D=pl.col(\"成交金额\")- pl.col(\"成交金额2\"),\n",
    ")  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 267,
   "id": "450c0961-e6ed-41f1-9fc5-288d99e9e6bf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (363, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th><th>成交金额2</th><th>成交金额D</th></tr><tr><td>str</td><td>date</td><td>time</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:38:10</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>13.2062</td><td>10400.0</td><td>137344.0</td><td>21.98</td><td>137.35</td><td>1.38</td><td>0.0</td><td>137184.67</td><td>137344.48</td><td>-0.48</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:44:52</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>3.19</td><td>47000.0</td><td>149930.0</td><td>23.99</td><td>0.0</td><td>1.51</td><td>0.0</td><td>-149955.5</td><td>149930.0</td><td>0.0</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:44:31</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>12.6066</td><td>11900.0</td><td>150019.0</td><td>24.0</td><td>0.0</td><td>1.49</td><td>0.0</td><td>-150044.49</td><td>150018.54</td><td>0.46</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:43:38</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;买入&quot;</td><td>3.69</td><td>40700.0</td><td>150183.0</td><td>24.03</td><td>0.0</td><td>1.5</td><td>0.0</td><td>-150208.53</td><td>150183.0</td><td>0.0</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:42:51</td><td>&quot;600015&quot;</td><td>&quot;华夏银行&quot;</td><td>&quot;买入&quot;</td><td>5.07</td><td>30000.0</td><td>152100.0</td><td>24.34</td><td>0.0</td><td>1.52</td><td>0.0</td><td>-152125.86</td><td>152100.0</td><td>0.0</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-18</td><td>09:46:15</td><td>&quot;300464&quot;</td><td>&quot;星徽股份&quot;</td><td>&quot;卖出&quot;</td><td>5.74</td><td>16100.0</td><td>92414.0</td><td>8.82</td><td>46.21</td><td>0.0</td><td>0.0</td><td>92358.97</td><td>92414.0</td><td>0.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-18</td><td>09:55:41</td><td>&quot;002661&quot;</td><td>&quot;克明食品&quot;</td><td>&quot;买入&quot;</td><td>9.42</td><td>8500.0</td><td>80072.0</td><td>7.64</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-80079.64</td><td>80070.0</td><td>2.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-09</td><td>09:48:02</td><td>&quot;002753&quot;</td><td>&quot;永东股份&quot;</td><td>&quot;买入&quot;</td><td>7.02</td><td>14200.0</td><td>99684.0</td><td>9.51</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-99693.51</td><td>99684.0</td><td>0.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-09</td><td>09:45:18</td><td>&quot;000698&quot;</td><td>&quot;沈阳化工&quot;</td><td>&quot;卖出&quot;</td><td>4.053</td><td>23800.0</td><td>96460.0</td><td>9.2</td><td>48.24</td><td>0.0</td><td>0.0</td><td>96402.56</td><td>96461.4</td><td>-1.4</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-09</td><td>09:44:40</td><td>&quot;605288&quot;</td><td>&quot;凯迪股份&quot;</td><td>&quot;卖出&quot;</td><td>40.838</td><td>2500.0</td><td>102094.0</td><td>9.74</td><td>51.05</td><td>1.0</td><td>0.0</td><td>102032.21</td><td>102095.0</td><td>-1.0</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (363, 16)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 券商    ┆ 交易日  ┆ 交易时  ┆ 证券代 ┆ … ┆ 其他费 ┆ 发生金 ┆ 成交金 ┆ 成交金 │\n",
       "│ ---     ┆ 期      ┆ 间      ┆ 码     ┆   ┆ ---    ┆ 额     ┆ 额2    ┆ 额D    │\n",
       "│ str     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ f64    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│         ┆ date    ┆ time    ┆ str    ┆   ┆        ┆ f64    ┆ f64    ┆ f64    │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 湘财    ┆ 2022-07 ┆ 09:38:1 ┆ 002462 ┆ … ┆ 0.0    ┆ 137184 ┆ 137344 ┆ -0.48  │\n",
       "│         ┆ -18     ┆ 0       ┆        ┆   ┆        ┆ .67    ┆ .48    ┆        │\n",
       "│ 湘财    ┆ 2022-07 ┆ 09:44:5 ┆ 600408 ┆ … ┆ 0.0    ┆ -14995 ┆ 149930 ┆ 0.0    │\n",
       "│         ┆ -18     ┆ 2       ┆        ┆   ┆        ┆ 5.5    ┆ .0     ┆        │\n",
       "│ 湘财    ┆ 2022-07 ┆ 09:44:3 ┆ 600648 ┆ … ┆ 0.0    ┆ -15004 ┆ 150018 ┆ 0.46   │\n",
       "│         ┆ -18     ┆ 1       ┆        ┆   ┆        ┆ 4.49   ┆ .54    ┆        │\n",
       "│ 湘财    ┆ 2022-07 ┆ 09:43:3 ┆ 600269 ┆ … ┆ 0.0    ┆ -15020 ┆ 150183 ┆ 0.0    │\n",
       "│         ┆ -18     ┆ 8       ┆        ┆   ┆        ┆ 8.53   ┆ .0     ┆        │\n",
       "│ 湘财    ┆ 2022-07 ┆ 09:42:5 ┆ 600015 ┆ … ┆ 0.0    ┆ -15212 ┆ 152100 ┆ 0.0    │\n",
       "│         ┆ -18     ┆ 1       ┆        ┆   ┆        ┆ 5.86   ┆ .0     ┆        │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:46:1 ┆ 300464 ┆ … ┆ 0.0    ┆ 92358. ┆ 92414. ┆ 0.0    │\n",
       "│ 融      ┆ -18     ┆ 5       ┆        ┆   ┆        ┆ 97     ┆ 0      ┆        │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:55:4 ┆ 002661 ┆ … ┆ 0.0    ┆ -80079 ┆ 80070. ┆ 2.0    │\n",
       "│ 融      ┆ -18     ┆ 1       ┆        ┆   ┆        ┆ .64    ┆ 0      ┆        │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:48:0 ┆ 002753 ┆ … ┆ 0.0    ┆ -99693 ┆ 99684. ┆ 0.0    │\n",
       "│ 融      ┆ -09     ┆ 2       ┆        ┆   ┆        ┆ .51    ┆ 0      ┆        │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:45:1 ┆ 000698 ┆ … ┆ 0.0    ┆ 96402. ┆ 96461. ┆ -1.4   │\n",
       "│ 融      ┆ -09     ┆ 8       ┆        ┆   ┆        ┆ 56     ┆ 4      ┆        │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:44:4 ┆ 605288 ┆ … ┆ 0.0    ┆ 102032 ┆ 102095 ┆ -1.0   │\n",
       "│ 融      ┆ -09     ┆ 0       ┆        ┆   ┆        ┆ .21    ┆ .0     ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 267,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.with_columns(\n",
    "    成交金额2=pl.col(\"成交价格\") * pl.col(\"成交数量\"),\n",
    ").with_columns(\n",
    "    成交金额D=pl.col(\"成交金额\")- pl.col(\"成交金额2\"),\n",
    ")  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 271,
   "id": "51c9ff72-dd55-407a-a618-148b73372748",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (363, 17)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th><th>成交金额2</th><th>成交金额D</th><th>发生金额D</th></tr><tr><td>str</td><td>date</td><td>time</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:38:10</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>13.2062</td><td>10400.0</td><td>137344.0</td><td>21.98</td><td>137.35</td><td>1.38</td><td>0.0</td><td>137184.67</td><td>137344.48</td><td>-0.48</td><td>1.38</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:44:52</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>3.19</td><td>47000.0</td><td>149930.0</td><td>23.99</td><td>0.0</td><td>1.51</td><td>0.0</td><td>-149955.5</td><td>149930.0</td><td>0.0</td><td>-299860.0</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:44:31</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>12.6066</td><td>11900.0</td><td>150019.0</td><td>24.0</td><td>0.0</td><td>1.49</td><td>0.0</td><td>-150044.49</td><td>150018.54</td><td>0.46</td><td>-300038.0</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:43:38</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;买入&quot;</td><td>3.69</td><td>40700.0</td><td>150183.0</td><td>24.03</td><td>0.0</td><td>1.5</td><td>0.0</td><td>-150208.53</td><td>150183.0</td><td>0.0</td><td>-300366.0</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:42:51</td><td>&quot;600015&quot;</td><td>&quot;华夏银行&quot;</td><td>&quot;买入&quot;</td><td>5.07</td><td>30000.0</td><td>152100.0</td><td>24.34</td><td>0.0</td><td>1.52</td><td>0.0</td><td>-152125.86</td><td>152100.0</td><td>0.0</td><td>-304200.0</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-18</td><td>09:46:15</td><td>&quot;300464&quot;</td><td>&quot;星徽股份&quot;</td><td>&quot;卖出&quot;</td><td>5.74</td><td>16100.0</td><td>92414.0</td><td>8.82</td><td>46.21</td><td>0.0</td><td>0.0</td><td>92358.97</td><td>92414.0</td><td>0.0</td><td>0.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-18</td><td>09:55:41</td><td>&quot;002661&quot;</td><td>&quot;克明食品&quot;</td><td>&quot;买入&quot;</td><td>9.42</td><td>8500.0</td><td>80072.0</td><td>7.64</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-80079.64</td><td>80070.0</td><td>2.0</td><td>-160144.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-09</td><td>09:48:02</td><td>&quot;002753&quot;</td><td>&quot;永东股份&quot;</td><td>&quot;买入&quot;</td><td>7.02</td><td>14200.0</td><td>99684.0</td><td>9.51</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-99693.51</td><td>99684.0</td><td>0.0</td><td>-199368.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-09</td><td>09:45:18</td><td>&quot;000698&quot;</td><td>&quot;沈阳化工&quot;</td><td>&quot;卖出&quot;</td><td>4.053</td><td>23800.0</td><td>96460.0</td><td>9.2</td><td>48.24</td><td>0.0</td><td>0.0</td><td>96402.56</td><td>96461.4</td><td>-1.4</td><td>0.0</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-09</td><td>09:44:40</td><td>&quot;605288&quot;</td><td>&quot;凯迪股份&quot;</td><td>&quot;卖出&quot;</td><td>40.838</td><td>2500.0</td><td>102094.0</td><td>9.74</td><td>51.05</td><td>1.0</td><td>0.0</td><td>102032.21</td><td>102095.0</td><td>-1.0</td><td>0.0</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (363, 17)\n",
       "┌─────────┬─────────┬─────────┬────────┬───┬────────┬────────┬────────┬────────┐\n",
       "│ 券商    ┆ 交易日  ┆ 交易时  ┆ 证券代 ┆ … ┆ 发生金 ┆ 成交金 ┆ 成交金 ┆ 发生金 │\n",
       "│ ---     ┆ 期      ┆ 间      ┆ 码     ┆   ┆ 额     ┆ 额2    ┆ 额D    ┆ 额D    │\n",
       "│ str     ┆ ---     ┆ ---     ┆ ---    ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---    │\n",
       "│         ┆ date    ┆ time    ┆ str    ┆   ┆ f64    ┆ f64    ┆ f64    ┆ f64    │\n",
       "╞═════════╪═════════╪═════════╪════════╪═══╪════════╪════════╪════════╪════════╡\n",
       "│ 湘财    ┆ 2022-07 ┆ 09:38:1 ┆ 002462 ┆ … ┆ 137184 ┆ 137344 ┆ -0.48  ┆ 1.38   │\n",
       "│         ┆ -18     ┆ 0       ┆        ┆   ┆ .67    ┆ .48    ┆        ┆        │\n",
       "│ 湘财    ┆ 2022-07 ┆ 09:44:5 ┆ 600408 ┆ … ┆ -14995 ┆ 149930 ┆ 0.0    ┆ -29986 │\n",
       "│         ┆ -18     ┆ 2       ┆        ┆   ┆ 5.5    ┆ .0     ┆        ┆ 0.0    │\n",
       "│ 湘财    ┆ 2022-07 ┆ 09:44:3 ┆ 600648 ┆ … ┆ -15004 ┆ 150018 ┆ 0.46   ┆ -30003 │\n",
       "│         ┆ -18     ┆ 1       ┆        ┆   ┆ 4.49   ┆ .54    ┆        ┆ 8.0    │\n",
       "│ 湘财    ┆ 2022-07 ┆ 09:43:3 ┆ 600269 ┆ … ┆ -15020 ┆ 150183 ┆ 0.0    ┆ -30036 │\n",
       "│         ┆ -18     ┆ 8       ┆        ┆   ┆ 8.53   ┆ .0     ┆        ┆ 6.0    │\n",
       "│ 湘财    ┆ 2022-07 ┆ 09:42:5 ┆ 600015 ┆ … ┆ -15212 ┆ 152100 ┆ 0.0    ┆ -30420 │\n",
       "│         ┆ -18     ┆ 1       ┆        ┆   ┆ 5.86   ┆ .0     ┆        ┆ 0.0    │\n",
       "│ …       ┆ …       ┆ …       ┆ …      ┆ … ┆ …      ┆ …      ┆ …      ┆ …      │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:46:1 ┆ 300464 ┆ … ┆ 92358. ┆ 92414. ┆ 0.0    ┆ 0.0    │\n",
       "│ 融      ┆ -18     ┆ 5       ┆        ┆   ┆ 97     ┆ 0      ┆        ┆        │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:55:4 ┆ 002661 ┆ … ┆ -80079 ┆ 80070. ┆ 2.0    ┆ -16014 │\n",
       "│ 融      ┆ -18     ┆ 1       ┆        ┆   ┆ .64    ┆ 0      ┆        ┆ 4.0    │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:48:0 ┆ 002753 ┆ … ┆ -99693 ┆ 99684. ┆ 0.0    ┆ -19936 │\n",
       "│ 融      ┆ -09     ┆ 2       ┆        ┆   ┆ .51    ┆ 0      ┆        ┆ 8.0    │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:45:1 ┆ 000698 ┆ … ┆ 96402. ┆ 96461. ┆ -1.4   ┆ 0.0    │\n",
       "│ 融      ┆ -09     ┆ 8       ┆        ┆   ┆ 56     ┆ 4      ┆        ┆        │\n",
       "│ 海通两  ┆ 2023-10 ┆ 09:44:4 ┆ 605288 ┆ … ┆ 102032 ┆ 102095 ┆ -1.0   ┆ 0.0    │\n",
       "│ 融      ┆ -09     ┆ 0       ┆        ┆   ┆ .21    ┆ .0     ┆        ┆        │\n",
       "└─────────┴─────────┴─────────┴────────┴───┴────────┴────────┴────────┴────────┘"
      ]
     },
     "execution_count": 271,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.with_columns(\n",
    "    成交金额2=pl.col(\"成交价格\") * pl.col(\"成交数量\"),\n",
    ").with_columns(\n",
    "    成交金额D=pl.col(\"成交金额\")- pl.col(\"成交金额2\"),\n",
    ").with_columns(\n",
    "    发生金额D=(\n",
    "        pl.col(\"发生金额\")\n",
    "        - (\n",
    "            pl.when(pl.col(\"买卖标志\") == \"买入\")\n",
    "            .then(pl.col(\"成交金额\"))\n",
    "            .when(pl.col(\"买卖标志\") == \"卖出\")\n",
    "            .then(pl.col(\"成交金额\"))\n",
    "            -pl.col(\"手续费\")\n",
    "            -pl.col(\"印花税\")\n",
    "            -pl.col(\"过户费\")\n",
    "            -pl.col(\"其他费\")\n",
    "         )\n",
    "    ).round(4)\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 272,
   "id": "c007a8f5-b485-45a5-825a-d0aeca285fd1",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.write_parquet(\"stock_trades.parquet\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 273,
   "id": "81e4ab43-4e7f-431e-958d-aa6e9df07847",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.write_csv(\"stock_trades.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cbed5957-3ea8-4f5f-be65-57ba8afa82d9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
